Class: Response::RaiseHttpErrors

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/faraday/response/raise_http_errors.rb', line 3

def on_complete(env)
  case env[:status].to_i
  when 400
    raise TropoRest::BadRequest, error_message(env)
  when 401
    raise TropoRest::NotAuthorized, error_message(env)
  when 403
    raise TropoRest::AccessDenied, error_message(env)
  when 404
    raise TropoRest::NotFound, error_message(env)
  when 405
    raise TropoRest::MethodNotAllowed, error_message(env)
  when 415
    raise TropoRest::UnsupportedMediaType, error_message(env)
  when 500
    raise TropoRest::InternalServerError, error_message(env)
  when 503
    raise TropoRest::ServiceUnavailable, error_message(env)
  end
end