pub enum RevertReason<T> {
ContractError(ContractError<T>),
RawString(String),
}
Expand description
Represents the reason for a revert in a smart contract.
This enum captures two possible scenarios for a revert:
-
ContractError
: Contains detailed error information, such as a specificRevert
orPanic
error. -
RawString
: Represents a raw string message as the reason for the revert.
Variants§
ContractError(ContractError<T>)
A detailed contract error, including a specific revert or panic error.
RawString(String)
Represents a raw string message as the reason for the revert.
Implementations§
Source§impl<T: SolInterface> RevertReason<T>
impl<T: SolInterface> RevertReason<T>
Sourcepub fn decode(out: &[u8]) -> Option<Self>
pub fn decode(out: &[u8]) -> Option<Self>
Decodes and retrieves the reason for a revert from the provided output data.
This method attempts to decode the provided output data as a generic contract error or a UTF-8 string (for Vyper reverts).
If successful, it returns the decoded revert reason wrapped in an Option
.
If both attempts fail, it returns None
.
Source§impl<T: SolInterface + Display> RevertReason<T>
impl<T: SolInterface + Display> RevertReason<T>
Source§impl<T> RevertReason<T>
impl<T> RevertReason<T>
Sourcepub fn as_raw_error(&self) -> Option<&str>
pub fn as_raw_error(&self) -> Option<&str>
Returns the raw string error message if this type is a RevertReason::RawString
Sourcepub const fn as_contract_error(&self) -> Option<&ContractError<T>>
pub const fn as_contract_error(&self) -> Option<&ContractError<T>>
Returns the ContractError
if this type is a RevertReason::ContractError
Sourcepub const fn is_custom_error(&self) -> bool
pub const fn is_custom_error(&self) -> bool
Returns true
if self
matches CustomError
.
Trait Implementations§
Source§impl<T: Clone> Clone for RevertReason<T>
impl<T: Clone> Clone for RevertReason<T>
Source§fn clone(&self) -> RevertReason<T>
fn clone(&self) -> RevertReason<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: Debug> Debug for RevertReason<T>
impl<T: Debug> Debug for RevertReason<T>
Source§impl<T: Display> Display for RevertReason<T>
impl<T: Display> Display for RevertReason<T>
Source§impl<T> From<ContractError<T>> for RevertReason<T>
Converts a ContractError<T>
into a RevertReason<T>
.
impl<T> From<ContractError<T>> for RevertReason<T>
Converts a ContractError<T>
into a RevertReason<T>
.
Source§fn from(error: ContractError<T>) -> Self
fn from(error: ContractError<T>) -> Self
Source§impl<T> From<Revert> for RevertReason<T>
Converts a Revert
into a RevertReason<T>
.
impl<T> From<Revert> for RevertReason<T>
Converts a Revert
into a RevertReason<T>
.
Source§impl<T> From<String> for RevertReason<T>
Converts a String
into a RevertReason<T>
.
impl<T> From<String> for RevertReason<T>
Converts a String
into a RevertReason<T>
.