module Camdram::Error

Public Class Methods

for(response) click to toggle source

This is called by the HTTP class when a request is not successful and is not a redirect

# File lib/camdram/error.rb, line 55
def self.for(response)
  code = response.code.to_i
  error_class = case code
                when 300..399
                  RedirectError
                when 400
                  BadRequest
                when 403
                  Forbidden
                when 404
                  NotFound
                when 401
                  Unauthorized
                when 429
                  RateLimit
                when 400..499
                  ClientError
                else
                  CamdramError
                end
  error_class.new(code, response.body, response.header)
end