Exception: Letterapp::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Letterapp::Error
- Defined in:
- lib/letterapp/client.rb
Overview
Raised for client misconfiguration and non-retryable API errors.
code is the API's machine-readable error code (bad_request, forbidden,
...). reason is the finer-grained cause when a send was refused
(suppressed, account_suspended, email_quota_exceeded, daily_cap,
billing_required, provider_rejected), which is what tells "this one
recipient is unreachable" apart from "our account is blocked".
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(message, status: nil, body: nil, payload: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, status: nil, body: nil, payload: nil) ⇒ Error
Returns a new instance of Error.
24 25 26 27 28 29 30 31 |
# File 'lib/letterapp/client.rb', line 24 def initialize(, status: nil, body: nil, payload: nil) super() @status = status @body = body error = payload.is_a?(Hash) ? (payload["error"] || {}) : {} @code = error["code"] @reason = error["reason"] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
22 23 24 |
# File 'lib/letterapp/client.rb', line 22 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
22 23 24 |
# File 'lib/letterapp/client.rb', line 22 def code @code end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
22 23 24 |
# File 'lib/letterapp/client.rb', line 22 def reason @reason end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
22 23 24 |
# File 'lib/letterapp/client.rb', line 22 def status @status end |