Class: Usps::Faraday::Response::RaiseError

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/usps/faraday/response/raise_error.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



7
8
9
10
11
12
# File 'lib/usps/faraday/response/raise_error.rb', line 7

def on_complete(env)
  raise Usps::Api::Errors::TooManyRequestsError, env.response if env.status == 429
  return unless (body = env.body) && body['Error']

  raise Usps::Api::Errors::UspsError.new(body['Error'], env.response)
end