pub struct JsonRpcError {
pub code: i64,
pub message: String,
pub data: Option<Value>,
}
Expand description
A JSON-RPC 2.0 error
Fields§
§code: i64
The error code
message: String
The error message
data: Option<Value>
Additional data
Implementations§
Source§impl JsonRpcError
impl JsonRpcError
Sourcepub fn is_revert(&self) -> bool
pub fn is_revert(&self) -> bool
Determine if the error output of the neo_call
RPC request is a revert
Note that this may return false positives if called on an error from other RPC requests
Sourcepub fn as_revert_data(&self) -> Option<Bytes>
pub fn as_revert_data(&self) -> Option<Bytes>
Attempt to extract revert data from the JsonRpcError be recursively traversing the error’s data field
This returns the first hex it finds in the data object, and its
behavior may change with serde_json
internal changes.
If no hex object is found, it will return an empty bytes IFF the error is a revert
Inspired by neo-js logic: https://github.com/neo-io/neo.js/blob/9f990c57f0486728902d4b8e049536f2bb3487ee/packages/providers/src.ts/json-rpc-provider.ts#L25-L53
Trait Implementations§
Source§impl Clone for JsonRpcError
impl Clone for JsonRpcError
Source§fn clone(&self) -> JsonRpcError
fn clone(&self) -> JsonRpcError
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for JsonRpcError
impl Debug for JsonRpcError
Source§impl<'de> Deserialize<'de> for JsonRpcError
impl<'de> Deserialize<'de> for JsonRpcError
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for JsonRpcError
impl Display for JsonRpcError
Source§impl Error for JsonRpcError
impl Error for JsonRpcError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<JsonRpcError> for ClientError
impl From<JsonRpcError> for ClientError
Source§fn from(source: JsonRpcError) -> Self
fn from(source: JsonRpcError) -> Self
Converts to this type from the input type.
Source§impl From<JsonRpcError> for ProviderError
impl From<JsonRpcError> for ProviderError
Source§fn from(source: JsonRpcError) -> Self
fn from(source: JsonRpcError) -> Self
Converts to this type from the input type.
Source§impl PartialEq for JsonRpcError
impl PartialEq for JsonRpcError
impl StructuralPartialEq for JsonRpcError
Auto Trait Implementations§
impl Freeze for JsonRpcError
impl RefUnwindSafe for JsonRpcError
impl Send for JsonRpcError
impl Sync for JsonRpcError
impl Unpin for JsonRpcError
impl UnwindSafe for JsonRpcError
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.