Exception: YouCanBookMe::Error

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

Class Method Summary collapse

Class Method Details

.raise_from(response) ⇒ Object

Raises:

  • (klass)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/YouCanBookMe/client/error.rb', line 6

def raise_from(response)
  status = response.code
  return if (200..299).cover?(status)

  klass = case status
          when 400      then YouCanBookMe::BadRequest
          when 400..499 then YouCanBookMe::ClientError
          when 500 then YouCanBookMe::InternalServerError
          when 500..599 then YouCanBookMe::ServerError
          else YouCanBookMe::UnknownError
          end
  # FIXME
  raise klass, response.code
end