class Clc::CloudExceptions::Handler

Public Instance Methods

on_complete(response) click to toggle source
# 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

Private Instance Methods

error_message(response) click to toggle source
# File lib/clc/cloud_exceptions.rb, line 34
def error_message(response)
  "#{response[:status]} #{response[:url]} #{response[:body]}"
end