Exception: Quicopt::QuicoptError
- Defined in:
- lib/quicopt/client.rb
Overview
A non-2xx service response.
reason is the service's stable snake_case code (+size_exceeded+,
unsupported_model, quota_exhausted, not_done, too_many_inflight,
queue_full, parse_error, …) — match on it, not on the message. display
is the framed text to print; status_code the HTTP status.
Instance Attribute Summary collapse
-
#body ⇒ Hash
readonly
The decoded error body.
-
#display ⇒ String?
readonly
The server-rendered, ready-to-print message.
-
#reason ⇒ String?
readonly
The stable machine-readable reason code.
-
#status_code ⇒ Integer
readonly
The HTTP status code.
Instance Method Summary collapse
-
#initialize(status_code, body) ⇒ QuicoptError
constructor
A new instance of QuicoptError.
Constructor Details
#initialize(status_code, body) ⇒ QuicoptError
Returns a new instance of QuicoptError.
94 95 96 97 98 99 100 |
# File 'lib/quicopt/client.rb', line 94 def initialize(status_code, body) @status_code = status_code @body = body.is_a?(Hash) ? body : { "error" => body.to_s } @reason = @body["reason"] @display = @body["display"] super(@body["error"] || "HTTP #{status_code}") end |
Instance Attribute Details
#body ⇒ Hash (readonly)
Returns the decoded error body.
88 89 90 |
# File 'lib/quicopt/client.rb', line 88 def body @body end |
#display ⇒ String? (readonly)
Returns the server-rendered, ready-to-print message.
92 93 94 |
# File 'lib/quicopt/client.rb', line 92 def display @display end |
#reason ⇒ String? (readonly)
Returns the stable machine-readable reason code.
90 91 92 |
# File 'lib/quicopt/client.rb', line 90 def reason @reason end |
#status_code ⇒ Integer (readonly)
Returns the HTTP status code.
86 87 88 |
# File 'lib/quicopt/client.rb', line 86 def status_code @status_code end |