Exception: BSV::Wallet::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/bsv/wallet/errors.rb

Overview

Base error for all wallet operations. Carries a machine-readable code per the BRC-100 error structure and a wire-protocol stack string.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, code: 1, stack: '') ⇒ Error

Returns a new instance of Error.



10
11
12
13
14
# File 'lib/bsv/wallet/errors.rb', line 10

def initialize(message = nil, code: 1, stack: '')
  @code = code
  @wallet_stack = stack
  super(message || '')
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



8
9
10
# File 'lib/bsv/wallet/errors.rb', line 8

def code
  @code
end

#wallet_stackObject (readonly)

Returns the value of attribute wallet_stack.



8
9
10
# File 'lib/bsv/wallet/errors.rb', line 8

def wallet_stack
  @wallet_stack
end

Instance Method Details

#to_wireObject

Serialise to a hash suitable for embedding in a wire result frame. Never leaks Ruby’s internal backtrace — only the wallet_stack string.



18
19
20
# File 'lib/bsv/wallet/errors.rb', line 18

def to_wire
  { code: code, message: message.to_s, stack: wallet_stack.to_s }
end