Exception: Pluggy::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Pluggy::Error
- Defined in:
- lib/pluggy/errors.rb
Overview
Flat, one-level hierarchy off a single base carrying the whole HTTP transcript. Unlike Stripe there is no request id: the Pluggy spec documents zero response headers, so nothing reliable exists to capture.
Direct Known Subclasses
APIError, AuthenticationError, BadGatewayError, ConfigurationError, ConflictError, ConnectionError, InvalidRequestError, NotFoundError, PermissionError, RateLimitError
Instance Attribute Summary collapse
-
#api_message ⇒ Object
readonly
Returns the value of attribute api_message.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#code_description ⇒ Object
readonly
Returns the value of attribute code_description.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#http_body ⇒ Object
readonly
Returns the value of attribute http_body.
-
#http_headers ⇒ Object
readonly
Returns the value of attribute http_headers.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#json_body ⇒ Object
readonly
Returns the value of attribute json_body.
Instance Method Summary collapse
-
#initialize(message = nil, http_status: nil, http_body: nil, http_headers: nil, json_body: nil) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(message = nil, http_status: nil, http_body: nil, http_headers: nil, json_body: nil) ⇒ Error
Returns a new instance of Error.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pluggy/errors.rb', line 11 def initialize( = nil, http_status: nil, http_body: nil, http_headers: nil, json_body: nil) @http_status = http_status @http_body = http_body @http_headers = http_headers || {} @json_body = json_body if json_body.is_a?(Hash) @code = json_body["code"] @code_description = json_body["codeDescription"] @data = json_body["data"] end # The API's own text, undecorated. #message and #to_s append the # codeDescription because that is what you want in a log line; this is # here for when you want to render just the message. @api_message = || @json_body&.fetch("message", nil) || super(@api_message) end |
Instance Attribute Details
#api_message ⇒ Object (readonly)
Returns the value of attribute api_message.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def @api_message end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def code @code end |
#code_description ⇒ Object (readonly)
Returns the value of attribute code_description.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def code_description @code_description end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def data @data end |
#http_body ⇒ Object (readonly)
Returns the value of attribute http_body.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def http_body @http_body end |
#http_headers ⇒ Object (readonly)
Returns the value of attribute http_headers.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def http_headers @http_headers end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def http_status @http_status end |
#json_body ⇒ Object (readonly)
Returns the value of attribute json_body.
8 9 10 |
# File 'lib/pluggy/errors.rb', line 8 def json_body @json_body end |
Instance Method Details
#to_s ⇒ Object
31 32 33 |
# File 'lib/pluggy/errors.rb', line 31 def to_s @code_description ? "#{@api_message} (#{@code_description})" : @api_message end |