lib/pushbullet/client.rb in pushbullet_client-0.0.15 vs lib/pushbullet/client.rb in pushbullet_client-0.0.16
- old
+ new
@@ -51,23 +51,33 @@
unless @disable_limit
params['limit'] = @limit
end
- response = HTTParty.send(
+ begin
+ response = send_request(http_method, path, params, payload)
+ rescue => Socket::ResolutionError
+ # Retry once
+ # TODO: Add in retry amounts
+ response = send_request(http_method, path, params, payload)
+ end
+
+ end_time = micro_second_time_now
+ construct_response_object(response, path, start_time, end_time)
+ end
+
+ def send_request(http_method, path, params, payload)
+ HTTParty.send(
http_method.to_sym,
construct_base_path(path, params),
body: payload,
headers: {
'Access-Token': @access_token,
'Content-Type': 'application/json'
},
port: port,
format: :json
)
-
- end_time = micro_second_time_now
- construct_response_object(response, path, start_time, end_time)
end
def construct_response_object(response, path, start_time, end_time)
{
'body' => parse_body(response, path),