Exception: Infrawrench::ApiError
- 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
-
#body ⇒ Object
readonly
Parsed response body — a Hash for JSON, else the raw String.
-
#code ⇒ String?
readonly
Machine-readable error code, when the API sent one.
-
#http_method ⇒ String
readonly
HTTP method of the failed request, e.g.
-
#status ⇒ Integer
readonly
HTTP status code.
-
#url ⇒ String
readonly
Fully resolved URL of the failed request.
Instance Method Summary collapse
-
#initialize(status:, message:, code:, body:, http_method:, url:) ⇒ ApiError
constructor
A new instance of ApiError.
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() @status = status @code = code @body = body @http_method = http_method @url = url end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns 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 |
#code ⇒ String? (readonly)
Returns Machine-readable error code, when the API sent one.
44 45 46 |
# File 'lib/infrawrench/transport.rb', line 44 def code @code end |
#http_method ⇒ String (readonly)
Returns 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 |
#status ⇒ Integer (readonly)
Returns HTTP status code.
42 43 44 |
# File 'lib/infrawrench/transport.rb', line 42 def status @status end |
#url ⇒ String (readonly)
Returns Fully resolved URL of the failed request.
50 51 52 |
# File 'lib/infrawrench/transport.rb', line 50 def url @url end |