Exception: Strife::Error

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

Direct Known Subclasses

ClientError, ServerError

Defined Under Namespace

Classes: BadRequest, ClientError, InternalServerError, NotAuthorizedError, ServerError

Class Method Summary collapse

Class Method Details

.from_response(response) ⇒ Object



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

def self.from_response(response)
  status = response[:status].to_i

  if klass = case status
             when 400 then BadRequest
             when 401 then NotAuthorizedError
             when 500 then InternalServerError
             end
    klass.new(response)
  end
end