Exception: Onetime::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/onetime/errors.rb

Overview

Base class for errors returned by the API (HTTP status >= 400).

Carries the structured fields from the ADR-013 wire format ({ error:, error_type:, ... }) as well as the legacy v1 { message: } shape, so callers get a consistent interface across API versions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status: nil, error_type: nil, code: nil, field: nil, error_key: nil, retry_after: nil, entitlement: nil, body: nil, response: nil) ⇒ APIError

Returns a new instance of APIError.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/onetime/errors.rb', line 31

def initialize(message = nil, http_status: nil, error_type: nil, code: nil,
               field: nil, error_key: nil, retry_after: nil, entitlement: nil,
               body: nil, response: nil)
  super(message)
  @http_status = http_status
  @error_type  = error_type
  @code        = code
  @field       = field
  @error_key   = error_key
  @retry_after = retry_after
  @entitlement = entitlement
  @body        = body
  @response    = response
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def code
  @code
end

#entitlementObject (readonly)

Returns the value of attribute entitlement.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def entitlement
  @entitlement
end

#error_keyObject (readonly)

Returns the value of attribute error_key.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def error_key
  @error_key
end

#error_typeObject (readonly)

Returns the value of attribute error_type.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def error_type
  @error_type
end

#fieldObject (readonly)

Returns the value of attribute field.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def field
  @field
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def http_status
  @http_status
end

#responseObject (readonly)

Returns the value of attribute response.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def response
  @response
end

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



28
29
30
# File 'lib/onetime/errors.rb', line 28

def retry_after
  @retry_after
end