Exception: Oz::APIError

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

Overview

Base class for all errors that originate from interacting with the API.

Carries the HTTP status code, the (parsed) response body, a machine readable error code when the API provides one, and the request_id header so that failures can be correlated with server side logs.

Direct Known Subclasses

APIConnectionError, APIStatusError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status_code: nil, body: nil, code: nil, request_id: nil, response: nil) ⇒ APIError

Returns a new instance of APIError.



19
20
21
22
23
24
25
26
# File 'lib/oz/errors.rb', line 19

def initialize(message = nil, status_code: nil, body: nil, code: nil, request_id: nil, response: nil)
  super(message)
  @status_code = status_code
  @body = body
  @code = code
  @request_id = request_id
  @response = response
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



17
18
19
# File 'lib/oz/errors.rb', line 17

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



17
18
19
# File 'lib/oz/errors.rb', line 17

def code
  @code
end

#request_idObject (readonly)

Returns the value of attribute request_id.



17
18
19
# File 'lib/oz/errors.rb', line 17

def request_id
  @request_id
end

#responseObject (readonly)

Returns the value of attribute response.



17
18
19
# File 'lib/oz/errors.rb', line 17

def response
  @response
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



17
18
19
# File 'lib/oz/errors.rb', line 17

def status_code
  @status_code
end