Class: FaradayMiddleware::RaiseOnError

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/faraday/raise_on_error.rb', line 4

def on_complete(env)
  case env[:status]
  when 404
    raise Cambio::NotFoundError, build_message(env)
  when 401
    raise Cambio::UnauthorisedError, build_message(env)
  when 500
    raise Cambio::ServerError, build_message(env)
  when 400...600
    raise Cambio::Error, build_message(env)
  end
end