Exception: Api2Convert::ApiError

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

Overview

An HTTP error response (status >= 400).

Used directly for a 4xx with no more specific subclass; specific statuses map to the dedicated subclasses below.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code: 0, request_id: nil, body: nil) ⇒ ApiError

Returns a new instance of ApiError.



28
29
30
31
32
33
# File 'lib/api2convert/errors.rb', line 28

def initialize(message, status_code: 0, request_id: nil, body: nil)
  super(message)
  @status_code = status_code
  @request_id = request_id
  @body = body || {}
end

Instance Attribute Details

#bodyHash (readonly)

Returns the decoded JSON error body, or {} when absent/unparseable.

Returns:

  • (Hash)

    the decoded JSON error body, or {} when absent/unparseable.



26
27
28
# File 'lib/api2convert/errors.rb', line 26

def body
  @body
end

#request_idString? (readonly)

Returns the X-Request-Id response header, if any. Quote it in support requests.

Returns:

  • (String, nil)

    the X-Request-Id response header, if any. Quote it in support requests.



24
25
26
# File 'lib/api2convert/errors.rb', line 24

def request_id
  @request_id
end

#status_codeInteger (readonly)

Returns the HTTP status code.

Returns:

  • (Integer)

    the HTTP status code.



21
22
23
# File 'lib/api2convert/errors.rb', line 21

def status_code
  @status_code
end