Struct casper_json_rpc::Error
source · 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>,
source§impl PartialEq for Error
impl PartialEq for Error
impl Eq for Error
impl StructuralEq for Error
impl StructuralPartialEq for Error
Auto Trait Implementations§
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.