pub struct Error { /* private fields */ }Expand description
An object suitable to be returned in a JSON-RPC response as the “error” field.
See the JSON-RPC Specification for further details.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new<C: ErrorCodeT, T: Serialize>(
error_code: C,
additional_info: T,
) -> Self
pub fn new<C: ErrorCodeT, T: Serialize>( error_code: C, additional_info: T, ) -> Self
Returns a new Error, converting error_code to the “code” and “message” fields, and
JSON-encoding additional_info as the “data” field.
Other than when providing a ReservedErrorCode, the converted “code” must not fall in the
reserved range as defined in the JSON-RPC specification, i.e. it must not be between -32768
and -32100 inclusive.
Note that in an upcoming release, the restriction will be tightened to disallow error codes in the implementation-defined server-errors range. I.e. codes in the range -32768 to -32000 inclusive will be disallowed.
If the converted code is within the reserved range when it should not be, or if
JSON-encoding additional_data fails, the returned Self is built from
ReservedErrorCode::InternalError with the “data” field being a String providing more
info on the underlying error.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Error
impl<'de> Deserialize<'de> for Error
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Error
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more