Class: Response::RaiseHttp4xx

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



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

def on_complete(env)
  case env[:status].to_i
  when 400
    raise Cashstar::BadRequest.new(error_message(env), env[:response_headers])
  when 401
    raise Cashstar::Unauthorized.new(error_message(env), env[:response_headers])
  when 403
    raise Cashstar::Forbidden.new(error_message(env), env[:response_headers])
  when 404
    raise Cashstar::NotFound.new(error_message(env), env[:response_headers])
  when 406
    raise Cashstar::NotAcceptable.new(error_message(env), env[:response_headers])
  when 420
    raise Cashstar::EnhanceYourCalm.new(error_message(env), env[:response_headers])
  end
end