Class: Response::RaiseButterSandError

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/response/raise_butter_sand_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
# File 'lib/faraday/response/raise_butter_sand_error.rb', line 5

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