@@ -40,25 +40,28 @@ class Client
4040 # A custom error type if a contract interaction fails.
4141 class ContractExecutionError < StandardError ; end
4242
43- # Raised when an RPC call returns an error. Carries the optional
43+ # Raised when an RPC call returns an error. Carries the error code and the optional
4444 # hex-encoded error data to support custom error decoding.
4545 class RpcError < IOError
4646 attr_reader :data
47+ attr_reader :code
4748
4849 # Constructor for the {RpcError} class.
4950 #
5051 # @param message [String] the error message returned by the RPC.
5152 # @param data [String] optional hex encoded error data.
52- def initialize ( message , data = nil )
53+ # @param code [String] optional error code returned by the RPC.
54+ def initialize ( message , data = nil , code = nil )
5355 super ( message )
5456 @data = data
57+ @code = code
5558 end
5659 end
5760
5861 # Creates a new RPC-Client, either by providing an HTTP/S host, WS/S host,
5962 # or an IPC path. Supports basic authentication with username and password.
6063 #
61- # **Note**, this sets the folling gas defaults: {Tx::DEFAULT_PRIORITY_FEE}
64+ # **Note**, this sets the following gas defaults: {Tx::DEFAULT_PRIORITY_FEE}
6265 # and {Tx::DEFAULT_GAS_PRICE. Use {#max_priority_fee_per_gas} and
6366 # {#max_fee_per_gas} to set custom values prior to submitting transactions.
6467 #
@@ -483,7 +486,7 @@ def send_command(command, args)
483486 }
484487 output = JSON . parse ( send_request ( payload . to_json ) )
485488 if ( err = output [ "error" ] )
486- raise RpcError . new ( err [ "message" ] , err [ "data" ] )
489+ raise RpcError . new ( err [ "message" ] , err [ "data" ] , err [ "code" ] )
487490 end
488491 output
489492 end
0 commit comments