Class: MnClient::Response::RaiseError

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mn_client/response/raise_error.rb', line 8

def on_complete(env)
  case env[:status].to_i
  when 400
    raise MnClient::BadRequest.new(error_message(env))
  when 401
    raise MnClient::NotAuthorized.new(error_message(env))
  when 404
    raise MnClient::NotFound.new(error_message(env))
  when 400...500
    raise MnClient::BadRequest.new(error_message(env))
  end
end