Class: Clc::CloudExceptions::Handler

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/clc/cloud_exceptions.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/clc/cloud_exceptions.rb', line 13

def on_complete(response)
  case response[:status]
  when 400
    raise Clc::CloudExceptions::BadRequest, error_message(response)
  when 401
    raise Clc::CloudExceptions::Unauthorized, error_message(response)
  when 403
    raise Clc::CloudExceptions::Forbidden, error_message(response)
  when 404
    raise Clc::CloudExceptions::NotFound, error_message(response)
  when 405
    raise Clc::CloudExceptions::MethodNotAllowed, error_message(response)
  when 500
    raise Clc::CloudExceptions::InternalServerError, error_message(response)
  when 400..600
    raise Clc::CloudExceptions::UnknownError, error_message(response)
  end
end