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§

source

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.

source

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§

source

fn is_error_response(&self) -> bool

Returns true if the underlying error is a JSON-RPC error response

source

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§

source§

impl RpcError for ethers_providers::HttpClientError

source§

impl RpcError for IpcError

Available on crate feature ipc and (Unix or Windows) only.
source§

impl RpcError for MockError

source§

impl RpcError for ProviderError

source§

impl RpcError for QuorumError

source§

impl RpcError for RetryClientError

source§

impl RpcError for ethers_providers::legacy_ws::ClientError

Available on crate feature legacy-ws only.
source§

impl<Read, Write> RpcError for RwClientError<Read, Write>
where Read: JsonRpcClient, <Read as JsonRpcClient>::Error: RpcError + Sync + Send + 'static, Write: JsonRpcClient, <Write as JsonRpcClient>::Error: RpcError + Sync + Send + 'static,