Exception: ZeroClick::Sellers::Error
- Inherits:
-
StandardError
- Object
- StandardError
- ZeroClick::Sellers::Error
- Defined in:
- lib/zeroclick/sellers/errors.rb
Overview
Verification outcomes are values, not exceptions — a request with a bad signature is an expected event, not a programming mistake. Error is reserved for what the caller got wrong (malformed input) or what the environment did (the ZeroClick API unreachable or answering nonsense).
Constant Summary collapse
- DEFAULT_MESSAGES =
{ "api_response_invalid" => "The ZeroClick API response is malformed", "api_status_error" => "The ZeroClick API returned an unsuccessful status", "api_transport_error" => "The ZeroClick API request failed", "malformed_input" => "The SDK input is malformed", "signing_secret_resolution_failed" => "The signing secret could not be resolved" }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
A stable machine code.
-
#context ⇒ Object
readonly
A stable machine code.
-
#operation ⇒ Object
readonly
A stable machine code.
Instance Method Summary collapse
-
#initialize(code, operation:, message: nil, **context) ⇒ Error
constructor
A new instance of Error.
- #inspect ⇒ Object
Constructor Details
#initialize(code, operation:, message: nil, **context) ⇒ Error
Returns a new instance of Error.
21 22 23 24 25 26 27 |
# File 'lib/zeroclick/sellers/errors.rb', line 21 def initialize(code, operation:, message: nil, **context) code = code.to_s super( || DEFAULT_MESSAGES.fetch(code)) @code = code @operation = operation @context = { operation: operation }.merge(context).freeze end |
Instance Attribute Details
#code ⇒ Object (readonly)
A stable machine code. Match on this, never on the message.
19 20 21 |
# File 'lib/zeroclick/sellers/errors.rb', line 19 def code @code end |
#context ⇒ Object (readonly)
A stable machine code. Match on this, never on the message.
19 20 21 |
# File 'lib/zeroclick/sellers/errors.rb', line 19 def context @context end |
#operation ⇒ Object (readonly)
A stable machine code. Match on this, never on the message.
19 20 21 |
# File 'lib/zeroclick/sellers/errors.rb', line 19 def operation @operation end |
Instance Method Details
#inspect ⇒ Object
29 30 31 |
# File 'lib/zeroclick/sellers/errors.rb', line 29 def inspect "#<ZeroClick::Sellers::Error code=#{@code.inspect} context=#{@context.inspect}>" end |