Class: PaypalClient::Errors::Middleware
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- PaypalClient::Errors::Middleware
- Defined in:
- lib/paypal_client/errors.rb
Constant Summary collapse
- ERROR_MAP =
{ 400 => InvalidRequest, 401 => AuthenticationFailure, 403 => NotAuthorized, 404 => ResourceNotFound, 405 => MethodNotSupported, 406 => MediaTypeNotAcceptable, 415 => UnsupportedMediaType, 422 => UnprocessableEntity, 429 => RateLimitReached, 500 => InternalServerError, 503 => ServiceUnavailable }.freeze
Instance Method Summary collapse
Instance Method Details
#on_complete(response) ⇒ Object
60 61 62 63 64 |
# File 'lib/paypal_client/errors.rb', line 60 def on_complete(response) key = response[:status].to_i raise ERROR_MAP[key], response if ERROR_MAP.key? key raise Error, response if response.status >= 400 end |