Struct ethers_providers::JsonRpcError
source · 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 eth_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 ethers-js logic: https://github.com/ethers-io/ethers.js/blob/9f990c57f0486728902d4b8e049536f2bb3487ee/packages/providers/src.ts/json-rpc-provider.ts#L25-L53
sourcepub fn decode_revert_data<E: AbiDecode>(&self) -> Option<E>
pub fn decode_revert_data<E: AbiDecode>(&self) -> Option<E>
Decode revert data (if any) into a decodeable type
Trait Implementations§
source§impl Clone for JsonRpcError
impl Clone for JsonRpcError
source§fn clone(&self) -> JsonRpcError
fn clone(&self) -> JsonRpcError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
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)>
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 ClientError
Available on crate feature legacy-ws
only.
impl From<JsonRpcError> for ClientError
Available on crate feature
legacy-ws
only.source§fn from(source: JsonRpcError) -> Self
fn from(source: JsonRpcError) -> Self
Converts to this type from the input type.
source§impl From<JsonRpcError> for IpcError
Available on crate feature ipc
and (Unix or Windows) only.
impl From<JsonRpcError> for IpcError
Available on crate feature
ipc
and (Unix or Windows) only.source§fn from(source: JsonRpcError) -> Self
fn from(source: JsonRpcError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
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