Permalink
Browse files

Log timeout errors

  • Loading branch information...
1 parent 3dfeb63 commit 5afcf8e86260b40308101acaf70d23eed85718f4 @tmak tmak committed Feb 2, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 lib/ops/core_api_call.rb
View
@@ -32,13 +32,19 @@ def request(api_method, options)
response = nil
start_time = Time.now
- @http.start do |http|
- request = Net::HTTP::Post.new(@uri.path)
- # Tweak headers, removing this will default to application/x-www-form-urlencoded
- request["Content-Type"] = "application/json"
- request.form_data = options
+ request = Net::HTTP::Post.new(@uri.path)
+ # Tweak headers, removing this will default to application/x-www-form-urlencoded
+ request["Content-Type"] = "application/json"
+ request.form_data = options
- response = http.request(request)
+ begin
+ @http.start do |http|
+ response = http.request(request)
+ end
+ rescue Timeout::Error
+ query_time = Time.now - start_time
+ OPS.log(self, "Timeout after #{query_time} seconds")
+ raise
end
response_time = Time.now

0 comments on commit 5afcf8e

Please sign in to comment.