Class: Response::RaiseDmmError

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

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ Object



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

def on_complete(response)
  case response[:status]
  when 400
    raise Dmm::BadRequest,          error_message(response)
  when 401
    raise Dmm::Unauthorized,        error_message(response)
  when 403
    raise Dmm::Forbidden,           error_message(response)
  when 404
    raise Dmm::NotFound,            error_message(response)
  when 406
    raise Dmm::NotAcceptable,       error_message(response)
  when 422
    raise Dmm::UnprocessableEntity, error_message(response)
  when 500
    raise Dmm::InternalServerError, error_message(response)
  when 503
    raise Dmm::ServiceUnavailable,  error_message(response)
  end
end