Class: Zendesk::Response::RaiseHttp4xx

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/zendesk/response/raise_http_4xx.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/zendesk/response/raise_http_4xx.rb', line 20

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