Exception: Cryptohopper::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Cryptohopper::Error
- Defined in:
- lib/cryptohopper/errors.rb
Overview
Single exception raised by every SDK call on non-2xx responses (and on network/timeout failures). Unknown server codes pass through as-is on ‘#code` so callers can handle new codes without waiting for an SDK update.
Constant Summary collapse
- KNOWN_CODES =
%w[ VALIDATION_ERROR UNAUTHORIZED FORBIDDEN NOT_FOUND CONFLICT RATE_LIMITED SERVER_ERROR SERVICE_UNAVAILABLE DEVICE_UNAUTHORIZED NETWORK_ERROR TIMEOUT UNKNOWN ].freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
-
#retry_after_ms ⇒ Object
readonly
Returns the value of attribute retry_after_ms.
-
#server_code ⇒ Object
readonly
Returns the value of attribute server_code.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(code:, message:, status:, server_code: nil, ip_address: nil, retry_after_ms: nil) ⇒ Error
constructor
A new instance of Error.
- #inspect ⇒ Object
Constructor Details
#initialize(code:, message:, status:, server_code: nil, ip_address: nil, retry_after_ms: nil) ⇒ Error
Returns a new instance of Error.
26 27 28 29 30 31 32 33 34 |
# File 'lib/cryptohopper/errors.rb', line 26 def initialize(code:, message:, status:, server_code: nil, ip_address: nil, retry_after_ms: nil) super() @code = code @status = status @server_code = server_code @ip_address = ip_address @retry_after_ms = retry_after_ms end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
24 25 26 |
# File 'lib/cryptohopper/errors.rb', line 24 def code @code end |
#ip_address ⇒ Object (readonly)
Returns the value of attribute ip_address.
24 25 26 |
# File 'lib/cryptohopper/errors.rb', line 24 def ip_address @ip_address end |
#retry_after_ms ⇒ Object (readonly)
Returns the value of attribute retry_after_ms.
24 25 26 |
# File 'lib/cryptohopper/errors.rb', line 24 def retry_after_ms @retry_after_ms end |
#server_code ⇒ Object (readonly)
Returns the value of attribute server_code.
24 25 26 |
# File 'lib/cryptohopper/errors.rb', line 24 def server_code @server_code end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
24 25 26 |
# File 'lib/cryptohopper/errors.rb', line 24 def status @status end |
Instance Method Details
#inspect ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/cryptohopper/errors.rb', line 36 def inspect extras = [] extras << "server_code=#{@server_code}" if @server_code extras << "ip=#{@ip_address}" if @ip_address extras << "retry_after_ms=#{@retry_after_ms}" if @retry_after_ms extra = extras.empty? ? "" : " (#{extras.join(", ")})" "#<Cryptohopper::Error code=#{@code} status=#{@status}#{extra}: #{}>" end |