Trait ethers_providers::RpcError
source · pub trait RpcError: Error + Debug + Send + Sync {
// Required methods
fn as_error_response(&self) -> Option<&JsonRpcError>;
fn as_serde_error(&self) -> Option<&Error>;
// Provided methods
fn is_error_response(&self) -> bool { ... }
fn is_serde_error(&self) -> bool { ... }
}
Expand description
An RpcError
is an abstraction over error types returned by a
crate::JsonRpcClient
.
All clients can return JsonRpcError
responses, as
well as serde deserialization errors. However, because client errors are
typically type-erased via the ProviderError
, the error info can be
difficult to access. This trait provides convenient access to the
underlying error types.
This trait deals only with behavior that is common to all clients. Client-specific errorvariants cannot be accessed via this trait.
Required Methods§
sourcefn as_error_response(&self) -> Option<&JsonRpcError>
fn as_error_response(&self) -> Option<&JsonRpcError>
Access an underlying JSON-RPC error (if any)
Attempts to access an underlying JsonRpcError
. If the underlying
error is not a JSON-RPC error response, this function will return
None
.
sourcefn as_serde_error(&self) -> Option<&Error>
fn as_serde_error(&self) -> Option<&Error>
Access an underlying serde_json
error (if any)
Attempts to access an underlying serde_json::Error
. If the
underlying error is not a serde_json error, this function will return
None
.
§Implementor’s Note
When writing a stacked crate::JsonRpcClient
abstraction (e.g. a quorum
provider or retrying provider), be sure to account for serde_json
errors at your layer, as well as at lower layers.
Provided Methods§
sourcefn is_error_response(&self) -> bool
fn is_error_response(&self) -> bool
Returns true
if the underlying error is a JSON-RPC error response
sourcefn is_serde_error(&self) -> bool
fn is_serde_error(&self) -> bool
Returns true
if the underlying error is a serde_json (de)serialization
error. This method can be used to identify
Implementors§
impl RpcError for ethers_providers::HttpClientError
impl RpcError for IpcError
ipc
and (Unix or Windows) only.impl RpcError for MockError
impl RpcError for ProviderError
impl RpcError for QuorumError
impl RpcError for RetryClientError
impl RpcError for ethers_providers::legacy_ws::ClientError
legacy-ws
only.