diff options
author | Cheah Chu Yeow <chuyeow@gmail.com> | 2008-04-16 18:39:19 +0800 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-04-22 09:30:56 +1200 |
commit | cf32baf915442ffe153ec0e4d8148f147776c30a (patch) | |
tree | 9405205f0ab6ddfceb49043206aa034f33a53cc1 /activeresource/lib/active_resource | |
parent | 105910429d5873dce677ef32eef5f705e0625d86 (diff) | |
download | rails-cf32baf915442ffe153ec0e4d8148f147776c30a.tar.gz rails-cf32baf915442ffe153ec0e4d8148f147776c30a.tar.bz2 rails-cf32baf915442ffe153ec0e4d8148f147776c30a.zip |
Rescue from Timeout::Error in ActiveResource::Connection.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activeresource/lib/active_resource')
-rw-r--r-- | activeresource/lib/active_resource/connection.rb | 10 |
1 files changed, 10 insertions, 0 deletions
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. |