Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Retry on SocketErrors.

  • Loading branch information...
commit f530ba6ff5fb1764b78a757545abe1da9931ee77 1 parent 2ed2dcf
Joel Watson authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/zapi/base.rb
14 lib/zapi/base.rb
View
@@ -17,8 +17,12 @@ def self.get(path, params={})
"Content-Type" => "application/json"
}
}
- options.merge(:query => {:query => query_for(params)}) if params.any?
- response = api.get(options)
+ options.merge!(:query => {:query => query_for(params)}) if params.any?
+ begin
+ response = api.get(options)
+ rescue Excon::Errors::SocketError
+ retry
+ end
objectify(JSON.parse(response.body, :symbolize_keys => true))
end
@@ -28,7 +32,11 @@ def self.find(query)
end
def self.all
- @@cache ||= get("/#{name}.json")
+ begin
+ @@cache ||= get("/#{name}.json")
+ rescue Excon::Errors::SocketError
+ retry
+ end
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.