pub enum RpcError<E, ErrResp = Box<RawValue>> {
ErrorResp(ErrorPayload<ErrResp>),
NullResp,
UnsupportedFeature(&'static str),
LocalUsageError(Box<dyn Error + Send + Sync>),
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 + Send + Sync>)
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: RpcRecv,
impl<E, ErrResp> RpcError<E, ErrResp>where
ErrResp: RpcRecv,
Sourcepub const fn err_resp(err: ErrorPayload<ErrResp>) -> Self
pub const fn err_resp(err: ErrorPayload<ErrResp>) -> Self
Instantiate a new ErrorResp
from an error response.
Sourcepub fn local_usage(err: impl Error + Send + Sync + 'static) -> Self
pub fn local_usage(err: impl Error + Send + Sync + 'static) -> Self
Instantiate a new LocalUsageError
from a custom error.
Sourcepub fn local_usage_str(err: &str) -> Self
pub fn local_usage_str(err: &str) -> Self
Instantiate a new LocalUsageError
from a custom error message.
Sourcepub fn deser_err(err: Error, text: impl AsRef<str>) -> Self
pub fn deser_err(err: Error, text: impl AsRef<str>) -> Self
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) -> Self
pub const fn ser_err(err: Error) -> Self
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.
Trait Implementations§
Source§impl<E, ErrResp> Error for RpcError<E, ErrResp>
impl<E, ErrResp> Error for RpcError<E, ErrResp>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl<E, ErrResp> Freeze for RpcError<E, ErrResp>
impl<E, ErrResp = Box<RawValue>> !RefUnwindSafe for RpcError<E, ErrResp>
impl<E, ErrResp> Send for RpcError<E, ErrResp>
impl<E, ErrResp> Sync for RpcError<E, ErrResp>
impl<E, ErrResp> Unpin for RpcError<E, ErrResp>
impl<E, ErrResp = Box<RawValue>> !UnwindSafe for RpcError<E, ErrResp>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.