Exception: Fopost::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Fopost::Error
- Defined in:
- lib/fopost/errors.rb
Overview
Direct Known Subclasses
AuthenticationError, NotFoundError, PaymentRequiredError, PermissionDeniedError, RateLimitError, ValidationError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
The message the API sent, undecorated.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(message, status:, code: nil, body: nil) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(message, status:, code: nil, body: nil) ⇒ Error
Returns a new instance of Error.
15 16 17 18 19 20 21 |
# File 'lib/fopost/errors.rb', line 15 def initialize(, status:, code: nil, body: nil) super() @message = @status = status @code = code @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/fopost/errors.rb', line 9 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/fopost/errors.rb', line 9 def code @code end |
#message ⇒ Object (readonly)
The message the API sent, undecorated. to_s adds the status and code,
so an uncaught error still reports both.
13 14 15 |
# File 'lib/fopost/errors.rb', line 13 def @message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/fopost/errors.rb', line 9 def status @status end |
Instance Method Details
#to_s ⇒ Object
23 24 25 26 |
# File 'lib/fopost/errors.rb', line 23 def to_s suffix = code ? " (#{code})" : '' "[#{status}#{suffix}] #{@message}" end |