Exception: StraddlePay::Error
- Inherits:
-
StandardError
- Object
- StandardError
- StraddlePay::Error
- Defined in:
- lib/straddle_pay/errors.rb
Overview
Base error for all Straddle API errors.
Direct Known Subclasses
AuthenticationError, ClientError, NetworkError, RateLimitError, ServerError, SignatureVerificationError
Instance Attribute Summary collapse
-
#body ⇒ Hash?
readonly
Full response body.
-
#error_items ⇒ Array<Hash>
readonly
Straddle error items with reference and detail.
-
#error_type ⇒ String?
readonly
Straddle error type (e.g. "validation_error").
-
#status ⇒ Integer?
readonly
HTTP status code.
Instance Method Summary collapse
-
#initialize(message = nil, status: nil, body: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message = nil, status: nil, body: nil) ⇒ Error
Returns a new instance of Error.
24 25 26 27 28 29 30 31 |
# File 'lib/straddle_pay/errors.rb', line 24 def initialize( = nil, status: nil, body: nil) error_hash = body.is_a?(Hash) ? (body["error"] || {}) : {} @error_type = error_hash["type"] if error_hash.is_a?(Hash) @error_items = (error_hash.is_a?(Hash) ? error_hash["items"] : nil) || [] super() @status = status @body = body end |
Instance Attribute Details
#body ⇒ Hash? (readonly)
Returns full response body.
15 16 17 |
# File 'lib/straddle_pay/errors.rb', line 15 def body @body end |
#error_items ⇒ Array<Hash> (readonly)
Returns Straddle error items with reference and detail.
19 20 21 |
# File 'lib/straddle_pay/errors.rb', line 19 def error_items @error_items end |
#error_type ⇒ String? (readonly)
Returns Straddle error type (e.g. "validation_error").
17 18 19 |
# File 'lib/straddle_pay/errors.rb', line 17 def error_type @error_type end |
#status ⇒ Integer? (readonly)
Returns HTTP status code.
13 14 15 |
# File 'lib/straddle_pay/errors.rb', line 13 def status @status end |