class Cased::HTTP::Error
Constants
- BadGateway
502
- BadRequest
400
- ClientError
4xx
- Conflict
409
- ERRORS
- Forbidden
403
- GatewayTimeout
504
- InternalServerError
500
- NotAcceptable
406
- NotFound
404
- RedirectionError
3xx
- RequestTimeout
408
- ServerError
5xx
503
- TooManyRequests
429
401
- UnprocessableEntity
422
Attributes
code[R]
json[R]
Public Class Methods
class_from_response(response)
click to toggle source
# File lib/cased/http/error.rb, line 22 def self.class_from_response(response) klass = ERRORS[response.status] if klass klass elsif (300...400).cover?(response.status) RedirectionError elsif (400...500).cover?(response.status) ClientError elsif (500...600).cover?(response.status) ServerError else self end end
from_response(response)
click to toggle source
# File lib/cased/http/error.rb, line 18 def self.from_response(response) new(response.body, response.status) end
new(json = {}, code = nil)
click to toggle source
Calls superclass method
# File lib/cased/http/error.rb, line 12 def initialize(json = {}, code = nil) @json = json @code = code super(JSON.dump(@json)) end