Exception: Recurly::Transaction::Error
- Inherits:
-
API::UnprocessableEntity
- Object
- StandardError
- Error
- API::ResponseError
- API::ClientError
- API::UnprocessableEntity
- Recurly::Transaction::Error
- Defined in:
- lib/recurly/transaction/errors.rb
Overview
The base error class for transaction errors, raised when a transaction fails.
Error messages are customer-friendly, though only DeclinedError messages should be a part of the normal API flow (a ConfigurationError, for example, is a problem that a customer cannot solve and requires your attention).
If a record of the transaction was stored in Recurly, it will be accessible via #transaction.
Direct Known Subclasses
Constant Summary collapse
- CATEGORY_MAP =
Hash.new DeclinedError
Instance Attribute Summary collapse
-
#transaction ⇒ Transaction
readonly
The transaction as returned (or updated) by Recurly.
Attributes inherited from API::ResponseError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request, response, transaction) ⇒ Error
constructor
A new instance of Error.
-
#to_s ⇒ String
A customer-friendly error message.
Methods inherited from API::ResponseError
#code, #description, #details, #symbol
Methods inherited from Error
Constructor Details
#initialize(request, response, transaction) ⇒ Error
Returns a new instance of Error.
32 33 34 35 |
# File 'lib/recurly/transaction/errors.rb', line 32 def initialize request, response, transaction super request, response update_transaction transaction end |
Instance Attribute Details
#transaction ⇒ Transaction (readonly)
Returns The transaction as returned (or updated) by Recurly.
30 31 32 |
# File 'lib/recurly/transaction/errors.rb', line 30 def transaction @transaction end |
Class Method Details
.validate!(exception, transaction) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/recurly/transaction/errors.rb', line 87 def validate! exception, transaction return unless exception.is_a? API::UnprocessableEntity category = exception.send(:xml).text( '/errors/transaction_error/error_category' ) and raise CATEGORY_MAP[category].new( exception.request, exception.response, transaction ) end |
Instance Method Details
#to_s ⇒ String
Returns A customer-friendly error message.
38 39 40 |
# File 'lib/recurly/transaction/errors.rb', line 38 def to_s xml.text '/errors/transaction_error/customer_message' end |