Skip to content

Commit

Permalink
Merge pull request amro#186 from zawaideh/patch-1
Browse files Browse the repository at this point in the history
capture :status_code and :raw_body
  • Loading branch information
amro committed Mar 16, 2016
2 parents 9f340ed + 5539dae commit ae9ec6b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/gibbon/api_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def handle_error(error)

begin
if error.is_a?(Faraday::Error::ClientError) && error.response
error_params[:status_code] = error.response[:status]
error_params[:raw_body] = error.response[:body]

parsed_response = MultiJson.load(error.response[:body])

if parsed_response
Expand All @@ -108,11 +111,8 @@ def handle_error(error)
error_params[:detail] = parsed_response["detail"] if parsed_response["detail"]
end

error_params[:status_code] = error.response[:status]
error_params[:raw_body] = error.response[:body]
end
rescue MultiJson::ParseError
error_params[:status_code] = error.response[:status]
end

error_to_raise = MailChimpError.new(error.message, error_params)
Expand Down

0 comments on commit ae9ec6b

Please sign in to comment.