Skip to content

Commit 1847163

Browse files
philippthunxiaozhu36
authored andcommitted
When rescuing from generic exceptions, don't rely on specifc fields
1 parent d5c9f4e commit 1847163

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/fog/aliyun/models/storage/files.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ def get(key, options = {}, &block)
7171
})
7272
new(file_data)
7373
rescue Exception => error
74-
case error.http_code.to_i
75-
when 404
76-
nil
77-
else
78-
raise(error)
74+
if error.respond_to?(:http_code) && error.http_code.to_i == 404
75+
nil
76+
else
77+
raise(error)
7978
end
8079
end
8180
end
@@ -108,11 +107,10 @@ def head(key, options = {})
108107
})
109108
new(file_data)
110109
rescue Exception => error
111-
case error.http_code.to_i
112-
when 404
113-
nil
114-
else
115-
raise(error)
110+
if error.respond_to?(:http_code) && error.http_code.to_i == 404
111+
nil
112+
else
113+
raise(error)
116114
end
117115
end
118116
end

0 commit comments

Comments
 (0)