Exception: Infrawrench::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/infrawrench/transport.rb,
sig/infrawrench/sdk.rbs

Overview

Raised for any non-2xx response.

Branch on #code rather than on the message — it carries the API's machine-readable discriminator (e.g. reauthentication_required on a step-up 403) whenever the response body has one.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, message:, code:, body:, http_method:, url:) ⇒ ApiError

Returns a new instance of ApiError.



52
53
54
55
56
57
58
59
# File 'lib/infrawrench/transport.rb', line 52

def initialize(status:, message:, code:, body:, http_method:, url:)
  super(message)
  @status = status
  @code = code
  @body = body
  @http_method = http_method
  @url = url
end

Instance Attribute Details

#bodyObject (readonly)

Returns Parsed response body — a Hash for JSON, else the raw String.

Returns:

  • (Object)

    Parsed response body — a Hash for JSON, else the raw String.



46
47
48
# File 'lib/infrawrench/transport.rb', line 46

def body
  @body
end

#codeString? (readonly)

Returns Machine-readable error code, when the API sent one.

Returns:

  • (String, nil)

    Machine-readable error code, when the API sent one.



44
45
46
# File 'lib/infrawrench/transport.rb', line 44

def code
  @code
end

#http_methodString (readonly)

Returns HTTP method of the failed request, e.g. "GET".

Returns:

  • (String)

    HTTP method of the failed request, e.g. "GET".



48
49
50
# File 'lib/infrawrench/transport.rb', line 48

def http_method
  @http_method
end

#statusInteger (readonly)

Returns HTTP status code.

Returns:

  • (Integer)

    HTTP status code.



42
43
44
# File 'lib/infrawrench/transport.rb', line 42

def status
  @status
end

#urlString (readonly)

Returns Fully resolved URL of the failed request.

Returns:

  • (String)

    Fully resolved URL of the failed request.



50
51
52
# File 'lib/infrawrench/transport.rb', line 50

def url
  @url
end