Class: AngellistApi::Response::RaiseClientError

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/angellist_api/response/raise_client_error.rb', line 12

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