Exception: Ingenico::Direct::SDK::ApiException
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Ingenico::Direct::SDK::ApiException
- Defined in:
- lib/ingenico/direct/sdk/api_exception.rb
Overview
Base class for many exceptions raised by the SDK. It is raised when an error response is received from the Ingenico ePayments platform. It contains data about the returned response.
Direct Known Subclasses
AuthorizationException, DeclinedTransactionException, DirectException, IdempotenceException, ReferenceException, ValidationException
Instance Attribute Summary collapse
-
#error_id ⇒ String
readonly
An error id corresponding to the error that occurred, if available.
-
#errors ⇒ Array<Ingenico::Direct::SDK::Domain::APIError>
readonly
A list of errors received from the Ingenico ePayments platform; may be empty but never nil.
-
#response_body ⇒ String
readonly
Message body of the returned response.
-
#status_code ⇒ Integer
readonly
HTTP status code of the returned response.
Instance Method Summary collapse
-
#initialize(status_code, response_body, error_id, errors, message = 'the Ingenico ePayments platform returned an error response') ⇒ ApiException
constructor
Creates a new ApiException that reports an error response from the Ingenico ePayments platform.
- #to_s ⇒ Object
Constructor Details
#initialize(status_code, response_body, error_id, errors, message = 'the Ingenico ePayments platform returned an error response') ⇒ ApiException
Creates a new ApiException that reports an error response from the Ingenico ePayments platform.
21 22 23 24 25 26 27 28 |
# File 'lib/ingenico/direct/sdk/api_exception.rb', line 21 def initialize(status_code, response_body, error_id, errors, = 'the Ingenico ePayments platform returned an error response') super() @status_code = status_code @response_body = response_body @error_id = error_id @errors = errors || [].freeze end |
Instance Attribute Details
#error_id ⇒ String (readonly)
An error id corresponding to the error that occurred, if available.
12 13 14 |
# File 'lib/ingenico/direct/sdk/api_exception.rb', line 12 def error_id @error_id end |
#errors ⇒ Array<Ingenico::Direct::SDK::Domain::APIError> (readonly)
A list of errors received from the Ingenico ePayments platform; may be empty but never nil
12 13 14 |
# File 'lib/ingenico/direct/sdk/api_exception.rb', line 12 def errors @errors end |
#response_body ⇒ String (readonly)
Message body of the returned response.
12 13 14 |
# File 'lib/ingenico/direct/sdk/api_exception.rb', line 12 def response_body @response_body end |
#status_code ⇒ Integer (readonly)
HTTP status code of the returned response.
12 13 14 |
# File 'lib/ingenico/direct/sdk/api_exception.rb', line 12 def status_code @status_code end |
Instance Method Details
#to_s ⇒ Object
35 36 37 38 39 40 |
# File 'lib/ingenico/direct/sdk/api_exception.rb', line 35 def to_s str = super.to_s str += "; status_code=#{@status_code}" if @status_code.positive? str += "; response_body='#{@response_body}'" if @response_body&.length&.positive? str.to_s end |