Exception: ZeroClick::Sellers::Error

Inherits:
StandardError
  • Object
show all
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

Instance Method Summary collapse

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(message || DEFAULT_MESSAGES.fetch(code))
  @code = code
  @operation = operation
  @context = { operation: operation }.merge(context).freeze
end

Instance Attribute Details

#codeObject (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

#contextObject (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

#operationObject (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

#inspectObject



29
30
31
# File 'lib/zeroclick/sellers/errors.rb', line 29

def inspect
  "#<ZeroClick::Sellers::Error code=#{@code.inspect} context=#{@context.inspect}>"
end