Exception: Solace::Errors::RPCError
- Inherits:
-
ConnectionError
- Object
- StandardError
- Error
- ConnectionError
- Solace::Errors::RPCError
- Defined in:
- lib/solace/errors/rpc_error.rb
Overview
Raised when the RPC node returns an error response.
This error is raised when the Solana RPC node successfully processes the HTTP request but returns an error in the JSON-RPC response. This includes errors like invalid parameters, insufficient funds, blockhash not found, and other RPC method-specific errors. The error message and code from the RPC response are included in the exception.
Instance Attribute Summary collapse
- #rpc_code ⇒ Object readonly
- #rpc_data ⇒ Object readonly
- #rpc_message ⇒ Object readonly
Class Method Summary collapse
-
.format_response(response) ⇒ Solace::Errors::RPCError
Formats a response to an error.
Instance Method Summary collapse
-
#initialize(message, rpc_code:, rpc_message:, rpc_data: nil) ⇒ RPCError
constructor
A new instance of RPCError.
-
#to_h ⇒ Hash
The error as a hash.
Constructor Details
#initialize(message, rpc_code:, rpc_message:, rpc_data: nil) ⇒ RPCError
Returns a new instance of RPCError.
29 30 31 32 33 34 |
# File 'lib/solace/errors/rpc_error.rb', line 29 def initialize(, rpc_code:, rpc_message:, rpc_data: nil) super() @rpc_code = rpc_code @rpc_message = @rpc_data = rpc_data end |
Instance Attribute Details
#rpc_code ⇒ Object (readonly)
23 24 25 |
# File 'lib/solace/errors/rpc_error.rb', line 23 def rpc_code @rpc_code end |
#rpc_data ⇒ Object (readonly)
23 24 25 |
# File 'lib/solace/errors/rpc_error.rb', line 23 def rpc_data @rpc_data end |
#rpc_message ⇒ Object (readonly)
23 24 25 |
# File 'lib/solace/errors/rpc_error.rb', line 23 def @rpc_message end |
Class Method Details
.format_response(response) ⇒ Solace::Errors::RPCError
Formats a response to an error
40 41 42 43 44 45 46 47 |
# File 'lib/solace/errors/rpc_error.rb', line 40 def self.format_response(response) new( "RPC error #{response['error']['code']}: #{response['error']['message']}", rpc_data: response['error']['data'], rpc_code: response['error']['code'], rpc_message: response['error']['message'] ) end |
Instance Method Details
#to_h ⇒ Hash
Returns The error as a hash.
50 |
# File 'lib/solace/errors/rpc_error.rb', line 50 def to_h = { code: rpc_code, message: , data: rpc_data } |