Exception: OnlinePayments::SDK::ApiException
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- OnlinePayments::SDK::ApiException
- Defined in:
- lib/onlinepayments/sdk/api_exception.rb
Overview
Represents an error response from the payment platform which contains an ID and a list of errors.
Direct Known Subclasses
AuthorizationException, DeclinedTransactionException, IdempotenceException, PlatformException, ReferenceException, ValidationException
Instance Attribute Summary collapse
-
#error_id ⇒ String
readonly
The errorId received from the Payment platform if available.
-
#errors ⇒ Array<OnlinePayments::SDK::Domain::APIError>
readonly
The errors received from the Payment platform if available; 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 payment platform returned an error response') ⇒ ApiException
constructor
Creates a new ApiException that reports an error response from the Payment platform.
- #to_s ⇒ Object
Constructor Details
#initialize(status_code, response_body, error_id, errors, message = 'the payment platform returned an error response') ⇒ ApiException
Creates a new ApiException that reports an error response from the Payment platform.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/onlinepayments/sdk/api_exception.rb', line 24 def initialize(status_code, response_body, error_id, errors, ='the payment platform returned an error response') super() @status_code = status_code @response_body = response_body @error_id = error_id if errors.nil? @errors = [].freeze else @errors = errors end end |
Instance Attribute Details
#error_id ⇒ String (readonly)
The errorId received from the Payment platform if available.
15 16 17 |
# File 'lib/onlinepayments/sdk/api_exception.rb', line 15 def error_id @error_id end |
#errors ⇒ Array<OnlinePayments::SDK::Domain::APIError> (readonly)
The errors received from the Payment platform if available; may be empty but never nil
15 16 17 |
# File 'lib/onlinepayments/sdk/api_exception.rb', line 15 def errors @errors end |
#response_body ⇒ String (readonly)
Message body of the returned response.
15 16 17 |
# File 'lib/onlinepayments/sdk/api_exception.rb', line 15 def response_body @response_body end |
#status_code ⇒ Integer (readonly)
HTTP status code of the returned response.
15 16 17 |
# File 'lib/onlinepayments/sdk/api_exception.rb', line 15 def status_code @status_code end |
Instance Method Details
#to_s ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/onlinepayments/sdk/api_exception.rb', line 42 def to_s str = super.to_s if @status_code > 0 str += '; status_code=' + @status_code.to_s end if !@response_body.nil? && @response_body.length > 0 str += "; response_body='" + @response_body + "'" end str.to_s end |