Exception: Jets::Api::Error

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

Defined Under Namespace

Modules: Handlers

Constant Summary collapse

@@http_errors =
{
  400 => "BadRequest",
  401 => "Unauthorized",
  403 => "Forbidden",
  404 => "NotFound",
  422 => "UnprocessableEntity",
  429 => "TooManyRequests",
  500 => "InternalServerError"
}
@@other_errors =

Do not correspond to http status codes

%w[
  Connection
  Maintenance
  ServiceUnavailable
]
@@error_classes =
@@http_errors.values + @@other_errors

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status: nil, http_body: nil, json_body: nil, http_headers: nil, code: nil) ⇒ Error

Returns a new instance of Error.



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

def initialize(message = nil, http_status: nil, http_body: nil,
  json_body: nil, http_headers: nil, code: nil)
  @message = message
  @http_status = http_status
  @http_body = http_body
  @http_headers = http_headers || {}
  @json_body = json_body
  @code = code
  @request_id = @http_headers["request-id"]
  super(message)
end