From cf32baf915442ffe153ec0e4d8148f147776c30a Mon Sep 17 00:00:00 2001 From: Cheah Chu Yeow Date: Wed, 16 Apr 2008 18:39:19 +0800 Subject: Rescue from Timeout::Error in ActiveResource::Connection. Signed-off-by: Michael Koziarski --- activeresource/lib/active_resource/connection.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activeresource/lib/active_resource/connection.rb') diff --git a/activeresource/lib/active_resource/connection.rb b/activeresource/lib/active_resource/connection.rb index 3b61009f43..98b3f87167 100644 --- a/activeresource/lib/active_resource/connection.rb +++ b/activeresource/lib/active_resource/connection.rb @@ -18,6 +18,14 @@ module ActiveResource end end + # Raised when a Timeout::Error occurs. + class TimeoutError < ConnectionError + def initialize(message) + @message = message + end + def to_s; @message ;end + end + # 3xx Redirection class Redirection < ConnectionError # :nodoc: def to_s; response['Location'] ? "#{super} => #{response['Location']}" : super; end @@ -134,6 +142,8 @@ module ActiveResource time = Benchmark.realtime { result = http.send(method, path, *arguments) } logger.info "--> #{result.code} #{result.message} (#{result.body ? result.body : 0}b %.2fs)" % time if logger handle_response(result) + rescue Timeout::Error => e + raise TimeoutError.new(e.message) end # Handles response and error codes from remote service. -- cgit v1.2.3