Method: Frontapp::Error.from_response

Defined in:
lib/frontapp/error.rb

.from_response(response) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/frontapp/error.rb', line 3

def self.from_response(response)
  error_class = case response.status
    when 400 then BadRequestError
    when 401 then UnauthorizedError
    when 404 then NotFoundError
    when 409 then ConflictError
    when 429 then TooManyRequestsError
    else self
    end
  error_class.new(response)
end