Enum ethers_contract::ContractError
source · pub enum ContractError<M: Middleware> {
DecodingError(Error),
AbiError(AbiError),
DetokenizationError(InvalidOutputType),
MiddlewareError {
e: M::Error,
},
ProviderError {
e: ProviderError,
},
Revert(Bytes),
ConstructorError,
ContractNotDeployed,
}
providers
only.Expand description
An Error which is thrown when interacting with a smart contract
Variants§
DecodingError(Error)
Thrown when the ABI decoding fails
AbiError(AbiError)
Thrown when the internal BaseContract errors
DetokenizationError(InvalidOutputType)
Thrown when detokenizing an argument
MiddlewareError
Thrown when a middleware call fails
ProviderError
Fields
e: ProviderError
The underlying error
Thrown when a provider call fails
Revert(Bytes)
Contract reverted
ConstructorError
Thrown during deployment if a constructor argument was passed in the deploy
call but a constructor was not present in the ABI
ContractNotDeployed
Thrown if a contract address is not found in the deployment transaction’s receipt
Implementations§
source§impl<M: Middleware> ContractError<M>
impl<M: Middleware> ContractError<M>
sourcepub fn as_revert(&self) -> Option<&Bytes>
pub fn as_revert(&self) -> Option<&Bytes>
If this ContractError
is a revert, this method will retrieve a
reference to the underlying revert data. This ABI-encoded data could be
a String, or a custom Solidity error type.
§Returns
None
if the error is not a revert
Some(data)
with the revert data, if the error is a revert
§Note
To skip this step, consider using ContractError::decode_revert
sourcepub fn decode_revert<Err: EthError>(&self) -> Option<Err>
pub fn decode_revert<Err: EthError>(&self) -> Option<Err>
Decode revert data into an EthError
type. Returns None
if
decoding fails, or if this is not a revert
sourcepub fn decode_contract_revert<Err: ContractRevert>(&self) -> Option<Err>
pub fn decode_contract_revert<Err: ContractRevert>(&self) -> Option<Err>
Decode revert data into a ContractRevert
type. Returns None
if
decoding fails, or if this is not a revert
This is intended to be used with error enum outputs from abigen!
contracts
sourcepub fn from_middleware_error(e: M::Error) -> Self
pub fn from_middleware_error(e: M::Error) -> Self
Convert a MiddlewareError
to a ContractError
sourcepub fn as_middleware_error(&self) -> Option<&M::Error>
pub fn as_middleware_error(&self) -> Option<&M::Error>
Convert a ContractError
to a MiddlewareError
if possible.
sourcepub fn is_middleware_error(&self) -> bool
pub fn is_middleware_error(&self) -> bool
True if the error is a middleware error
sourcepub fn as_provider_error(&self) -> Option<&ProviderError>
pub fn as_provider_error(&self) -> Option<&ProviderError>
Convert a ContractError
to a ProviderError
if possible.
sourcepub fn is_provider_error(&self) -> bool
pub fn is_provider_error(&self) -> bool
True if the error is a provider error
Trait Implementations§
source§impl<M: Debug + Middleware> Debug for ContractError<M>
impl<M: Debug + Middleware> Debug for ContractError<M>
source§impl<M: Middleware> Display for ContractError<M>
impl<M: Middleware> Display for ContractError<M>
source§impl<M: Middleware> Error for ContractError<M>
impl<M: Middleware> Error for ContractError<M>
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl<M: Middleware> From<AbiError> for ContractError<M>
impl<M: Middleware> From<AbiError> for ContractError<M>
source§impl<M: Middleware> From<ContractError<M>> for MulticallError<M>
Available on crate feature abigen
only.
impl<M: Middleware> From<ContractError<M>> for MulticallError<M>
abigen
only.