Exception: Billogram::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/billogram/error.rb

Defined Under Namespace

Classes: BadRequest, Forbidden, InternalServerError, NotFound, Unauthorized

Class Method Summary collapse

Class Method Details

.from_response(response) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/billogram/error.rb', line 10

def self.from_response(response)
  if klass =  case response.code.to_i
              when 400      then BadRequest
              when 401      then Unauthorized
              when 403      then Forbidden
              when 404      then NotFound
              when 500      then InternalServerError
              else               Billogram::Error
              end
    klass.new(response["data"]["message"])
  end
end