pub enum RpcError<E, ErrResp = Box<RawValue>> {
ErrorResp(ErrorPayload<ErrResp>),
NullResp,
UnsupportedFeature(&'static str),
LocalUsageError(Box<dyn Error + Sync + Send>),
SerError(Error),
DeserError {
err: Error,
text: String,
},
Transport(E),
}
Expand description
An RPC error.
Variants§
ErrorResp(ErrorPayload<ErrResp>)
Server returned an error response.
NullResp
Server returned a null response when a non-null response was expected.
UnsupportedFeature(&'static str)
Rpc server returned an unsupported feature.
LocalUsageError(Box<dyn Error + Sync + Send>)
Returned when a local pre-processing step fails. This allows custom errors from local signers or request pre-processors.
SerError(Error)
JSON serialization error.
DeserError
JSON deserialization error.
Fields
Transport(E)
Transport error.
This variant is used when the error occurs during communication.
Tuple Fields
0: E
The underlying transport error.
Implementations§
source§impl<E, ErrResp> RpcError<E, ErrResp>where
ErrResp: RpcReturn,
impl<E, ErrResp> RpcError<E, ErrResp>where
ErrResp: RpcReturn,
sourcepub const fn err_resp(err: ErrorPayload<ErrResp>) -> RpcError<E, ErrResp>
pub const fn err_resp(err: ErrorPayload<ErrResp>) -> RpcError<E, ErrResp>
Instantiate a new ErrorResp
from an error response.
sourcepub fn local_usage(
err: impl Error + Send + Sync + 'static,
) -> RpcError<E, ErrResp>
pub fn local_usage( err: impl Error + Send + Sync + 'static, ) -> RpcError<E, ErrResp>
Instantiate a new LocalUsageError
from a custom error.
sourcepub fn local_usage_str(err: &str) -> RpcError<E, ErrResp>
pub fn local_usage_str(err: &str) -> RpcError<E, ErrResp>
Instantiate a new LocalUsageError
from a custom error message.
sourcepub fn deser_err(err: Error, text: impl AsRef<str>) -> RpcError<E, ErrResp>
pub fn deser_err(err: Error, text: impl AsRef<str>) -> RpcError<E, ErrResp>
Instantiate a new DeserError
from a serde_json::Error
and the
text. This should be called when the error occurs during
deserialization.
Note: This will check if the response is actually an ErrorPayload, if so it will return a RpcError::ErrorResp.
source§impl<E, ErrResp> RpcError<E, ErrResp>
impl<E, ErrResp> RpcError<E, ErrResp>
sourcepub const fn ser_err(err: Error) -> RpcError<E, ErrResp>
pub const fn ser_err(err: Error) -> RpcError<E, ErrResp>
Instantiate a new SerError
from a serde_json::Error
. This
should be called when the error occurs during serialization.
sourcepub const fn is_ser_error(&self) -> bool
pub const fn is_ser_error(&self) -> bool
Check if the error is a serialization error.
sourcepub const fn is_deser_error(&self) -> bool
pub const fn is_deser_error(&self) -> bool
Check if the error is a deserialization error.
sourcepub const fn is_transport_error(&self) -> bool
pub const fn is_transport_error(&self) -> bool
Check if the error is a transport error.
sourcepub const fn is_error_resp(&self) -> bool
pub const fn is_error_resp(&self) -> bool
Check if the error is an error response.
sourcepub const fn is_null_resp(&self) -> bool
pub const fn is_null_resp(&self) -> bool
Check if the error is a null response.
sourcepub const fn is_unsupported_feature(&self) -> bool
pub const fn is_unsupported_feature(&self) -> bool
Check if the error is an unsupported feature error.
sourcepub const fn is_local_usage_error(&self) -> bool
pub const fn is_local_usage_error(&self) -> bool
Check if the error is a local usage error.
sourcepub const fn as_error_resp(&self) -> Option<&ErrorPayload<ErrResp>>
pub const fn as_error_resp(&self) -> Option<&ErrorPayload<ErrResp>>
Fallible conversion to an error response.