Exception: NodexPay::APIError
- Defined in:
- lib/nodex_pay/errors.rb,
sig/nodex_pay.rbs
Direct Known Subclasses
BadRequestError, ServiceUnavailableError, UnexpectedHTTPStatusError
Constant Summary collapse
- ERROR_NAMES =
{ 2010 => "RECEIVED_IDENTIFICATION_TOKEN_EMPTY", 2011 => "RECEIVED_IDENTIFICATION_TOKEN_INVALID", 2020 => "RECEIVED_ORDER_CODE_EMPTY", 2021 => "RECEIVED_ORDER_CODE_DUPLICATE", 2022 => "RECEIVED_ORDER_CODE_ALREADY_CANCELLED", 2023 => "PAYMENT_NOT_FOUND", 2024 => "PAYMENT_NOT_CANCELABLE", 2030 => "RECEIVED_AMOUNT_INVALID_FORMAT", 2040 => "RECEIVED_INVALID_CALLBACK_URL", 2050 => "RECEIVED_COLOR_THEME_INVALID_FORMAT", 2060 => "RECEIVED_VERIFY_TOKEN_EMPTY", 2061 => "RECEIVED_VERIFY_TOKEN_INVALID", 2101 => "RECEIVED_EXT_RESERVED_INVALID", 2102 => "RECEIVED_EXT_DESCRIPTION_INVALID", 2370 => "RECEIVE_CONTRACT_UNPUBLISHED", 2460 => "RECEIVED_INVALID_DEADLINE" }.freeze
Instance Attribute Summary collapse
-
#error_codes ⇒ Array[Integer]
readonly
Returns the value of attribute error_codes.
-
#operation ⇒ Symbol
readonly
Returns the value of attribute operation.
-
#response_body ⇒ String
readonly
Returns the value of attribute response_body.
-
#response_headers ⇒ Hash[String, String]
readonly
Returns the value of attribute response_headers.
-
#status ⇒ Integer
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(operation:, status:, error_codes:, response_headers:, response_body:) ⇒ APIError
constructor
A new instance of APIError.
- #inspect ⇒ Object
Constructor Details
#initialize(operation:, status:, error_codes:, response_headers:, response_body:) ⇒ APIError
Returns a new instance of APIError.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nodex_pay/errors.rb', line 35 def initialize(operation:, status:, error_codes:, response_headers:, response_body:) @operation = operation @status = status @error_codes = error_codes.map { Integer(_1) }.freeze @response_headers = response_headers.to_h.transform_keys(&:to_s).transform_values(&:to_s).freeze @response_body = response_body.to_s.dup.freeze details = @error_codes.map { |code| ERROR_NAMES.fetch(code, code.to_s) } suffix = details.empty? ? "" : " (#{details.join(", ")})" super("Nodex Pay #{operation} failed with HTTP #{status}#{suffix}") end |
Instance Attribute Details
#error_codes ⇒ Array[Integer] (readonly)
Returns the value of attribute error_codes.
33 34 35 |
# File 'lib/nodex_pay/errors.rb', line 33 def error_codes @error_codes end |
#operation ⇒ Symbol (readonly)
Returns the value of attribute operation.
33 34 35 |
# File 'lib/nodex_pay/errors.rb', line 33 def operation @operation end |
#response_body ⇒ String (readonly)
Returns the value of attribute response_body.
33 34 35 |
# File 'lib/nodex_pay/errors.rb', line 33 def response_body @response_body end |
#response_headers ⇒ Hash[String, String] (readonly)
Returns the value of attribute response_headers.
33 34 35 |
# File 'lib/nodex_pay/errors.rb', line 33 def response_headers @response_headers end |
#status ⇒ Integer (readonly)
Returns the value of attribute status.
33 34 35 |
# File 'lib/nodex_pay/errors.rb', line 33 def status @status end |
Instance Method Details
#inspect ⇒ Object
47 48 49 |
# File 'lib/nodex_pay/errors.rb', line 47 def inspect "#<#{self.class} operation=#{operation.inspect} status=#{status.inspect} error_codes=#{error_codes.inspect}>" end |