mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Make Model#reload more resilient against errors.
Connection errors had the behavior of failing catastrophically, which had some rather unpleasant implications for things like Model#wait_for, which implicitly reload repeatedly without any protection. This change may be better suited to special cases (e.g. Model#wait_for).
This commit is contained in:
parent
e71895f1a4
commit
331d58dabf
1 changed files with 9 additions and 4 deletions
|
@ -25,11 +25,16 @@ module Fog
|
|||
|
||||
def reload
|
||||
requires :identity
|
||||
if data = collection.get(identity)
|
||||
new_attributes = data.attributes
|
||||
merge_attributes(new_attributes)
|
||||
self
|
||||
|
||||
return unless data = begin
|
||||
collection.get(identity)
|
||||
rescue Excon::Errors::SocketError
|
||||
nil
|
||||
end
|
||||
|
||||
new_attributes = data.attributes
|
||||
merge_attributes(new_attributes)
|
||||
self
|
||||
end
|
||||
|
||||
def to_json
|
||||
|
|
Loading…
Add table
Reference in a new issue