Class: Response::RaiseInvoicexpressErrors

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/response/raise_invoicexpress_errors.rb

Constant Summary collapse

ERROR_MAP =
{
  401 => Invoicexpress::Unauthorized,
  422 => Invoicexpress::UnprocessableEntity,
  500 => Invoicexpress::InternalServerError,
}

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/faraday/response/raise_invoicexpress_errors.rb', line 12

def on_complete(env)
  key = env[:status].to_i

  if ERROR_MAP.has_key? key
    raise ERROR_MAP[key].new(env)
  end
end