lib/flexirest/request.rb in flexirest-1.3.10 vs lib/flexirest/request.rb in flexirest-1.3.12

- old
+ new

@@ -405,21 +405,21 @@ error_response = generate_new_object(mutable: false, ignore_xml_root: @method[:options][:ignore_xml_root]) else error_response = @response.body end if status == 400 - raise HTTPBadRequestClientException.new(status:status, result:error_response, url:@url) + raise HTTPBadRequestClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method) elsif status == 401 - raise HTTPUnauthorisedClientException.new(status:status, result:error_response, url:@url) + raise HTTPUnauthorisedClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method) elsif status == 403 - raise HTTPForbiddenClientException.new(status:status, result:error_response, url:@url) + raise HTTPForbiddenClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method) elsif status == 404 - raise HTTPNotFoundClientException.new(status:status, result:error_response, url:@url) + raise HTTPNotFoundClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method) elsif (400..499).include? status - raise HTTPClientException.new(status:status, result:error_response, url:@url) + raise HTTPClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method) elsif (500..599).include? status - raise HTTPServerException.new(status:status, result:error_response, url:@url) + raise HTTPServerException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method) elsif status == 0 raise TimeoutException.new("Timed out getting #{response.url}") end end @@ -601,9 +601,15 @@ attr_accessor :status, :result, :request_url def initialize(options) @status = options[:status] @result = options[:result] @request_url = options[:url] + @raw_response = options[:raw_response] + @method = options[:method] + end + + def message + "Sending #{@method.upcase} to '#{@request_url}' returned a #{@status} with the body of - #{@raw_response}" end end class HTTPClientException < HTTPException ; end class HTTPUnauthorisedClientException < HTTPClientException ; end class HTTPBadRequestClientException < HTTPClientException ; end