Class: PaypalClient::ErrorMiddleware

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/paypal_client.rb

Constant Summary collapse

ERROR_MAP =
{
  404 => NotFound
}.freeze

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ Object

Raises:

  • ()


114
115
116
117
118
# File 'lib/paypal_client.rb', line 114

def on_complete(response)
  key = response[:status].to_i
  raise ERROR_MAP[key], response if ERROR_MAP.key? key
  raise ResponseError, response if response.status >= 400
end