Exception: Billomat::GatewayError
- Inherits:
-
StandardError
- Object
- StandardError
- Billomat::GatewayError
- Defined in:
- lib/billomat/gateway.rb
Overview
Raised if something goes wrong during an API call.
Instance Attribute Summary collapse
-
#original_exception ⇒ Object
readonly
Returns the value of attribute original_exception.
Instance Method Summary collapse
-
#initialize(original_exception) ⇒ GatewayError
constructor
Create a new GatewayError from a RestClient exception.
Constructor Details
#initialize(original_exception) ⇒ GatewayError
Create a new GatewayError from a RestClient exception.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/billomat/gateway.rb', line 14 def initialize(original_exception) # Extract the error from the response if it is present. If no error # could be extracted, use the whole body body = original_exception.response&.body response_error = JSON.parse(body).dig('errors', 'error') || body if body # Use the default message and append our detailed error = original_exception. += " ('#{response_error}')" if response_error super() @original_exception = original_exception end |
Instance Attribute Details
#original_exception ⇒ Object (readonly)
Returns the value of attribute original_exception.
9 10 11 |
# File 'lib/billomat/gateway.rb', line 9 def original_exception @original_exception end |