Exception: OpenReceive::Server::Swap::FixedFloatApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/openreceive/server/swap/fixedfloat.rb

Overview

Ruby port of the FixedFloatApiError from packages/js/node/src/swap/fixedfloat.ts. Deliberately does NOT expose #status/#code: the request handler duck-types those for wire mapping, and a provider failure must reach the payer as the redacted 500 "Internal server error." exactly like the JS engine.

Constant Summary collapse

KINDS =
%w[api http invalid_json network rate_limited timeout].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, kind:, message:, http_status: nil, fixedfloat_code: nil, fixedfloat_message: nil) ⇒ FixedFloatApiError

Returns a new instance of FixedFloatApiError.



24
25
26
27
28
29
30
31
32
# File 'lib/openreceive/server/swap/fixedfloat.rb', line 24

def initialize(path:, kind:, message:, http_status: nil, fixedfloat_code: nil,
               fixedfloat_message: nil)
  super(message)
  @path = path
  @kind = kind
  @http_status = http_status
  @fixedfloat_code = fixedfloat_code
  @fixedfloat_message = fixedfloat_message
end

Instance Attribute Details

#fixedfloat_codeObject (readonly)

Returns the value of attribute fixedfloat_code.



22
23
24
# File 'lib/openreceive/server/swap/fixedfloat.rb', line 22

def fixedfloat_code
  @fixedfloat_code
end

#fixedfloat_messageObject (readonly)

Returns the value of attribute fixedfloat_message.



22
23
24
# File 'lib/openreceive/server/swap/fixedfloat.rb', line 22

def fixedfloat_message
  @fixedfloat_message
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



22
23
24
# File 'lib/openreceive/server/swap/fixedfloat.rb', line 22

def http_status
  @http_status
end

#kindObject (readonly)

Returns the value of attribute kind.



22
23
24
# File 'lib/openreceive/server/swap/fixedfloat.rb', line 22

def kind
  @kind
end

#pathObject (readonly)

Returns the value of attribute path.



22
23
24
# File 'lib/openreceive/server/swap/fixedfloat.rb', line 22

def path
  @path
end

Class Method Details

.from_transport_error(path, error) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/openreceive/server/swap/fixedfloat.rb', line 34

def self.from_transport_error(path, error)
  aborted = Swap.timeout_error?(error)
  new(
    path: path,
    kind: aborted ? "timeout" : "network",
    message: aborted ? "FixedFloat #{path} request timed out."
                     : "FixedFloat #{path} request failed before a response was received."
  )
end