class Faraday::Response::RaiseHttp5xx

Public Instance Methods

on_complete(env) click to toggle source
# File lib/faraday/raise_http_5xx.rb, line 6
def on_complete(env)
  env[:response].on_complete do |response|
    case response[:status].to_i
    when 500
      raise JustGiving::InternalServerError, error_message(response)
    end
  end
end

Private Instance Methods

error_body(body) click to toggle source
# File lib/faraday/raise_http_5xx.rb, line 21
def error_body(body)
  if body.nil?
    nil
  elsif body['error']
    body['error']['id']
  end
end
error_message(response) click to toggle source
# File lib/faraday/raise_http_5xx.rb, line 17
def error_message(response)
  "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]} #{error_body(response[:body])}"
end