From f9ea6bf5e31bd41bf2d419079270a35d991ef967 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Fri, 29 Jan 2010 16:03:43 -0500 Subject: [PATCH] RedirectionTooDeep contains the last response --- lib/httparty/exceptions.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/httparty/exceptions.rb b/lib/httparty/exceptions.rb index 88d0822..73ce4ea 100644 --- a/lib/httparty/exceptions.rb +++ b/lib/httparty/exceptions.rb @@ -5,6 +5,21 @@ module HTTParty # Exception raised when using a URI scheme other than HTTP or HTTPS class UnsupportedURIScheme < StandardError; end - # Exception that is raised when request has redirected too many times - class RedirectionTooDeep < StandardError; end + # @abstract Exceptions which inherit from ResponseError contain the Net::HTTP + # response object accessible via the {#response} method. + class ResponseError < StandardError + # Returns the response of the last request + # @return [Net::HTTPResponse] + attr_reader :response + + # Instantiate an instance of ResponseError with a Net::HTTPResponse object + # @param [Net::HTTPResponse] + def initialize(response) + @response = response + end + end + + # Exception that is raised when request has redirected too many times. + # Calling {#response} returns the Net:HTTP response object. + class RedirectionTooDeep < ResponseError; end end