ethers_core/abi/
error.rs

1//! Boilerplate error definitions.
2use crate::abi::{human_readable, InvalidOutputType};
3use thiserror::Error;
4
5/// A type alias for std's Result with the Error as our error type.
6pub type Result<T, E = ParseError> = std::result::Result<T, E>;
7
8/// Error that can occur during human readable parsing
9#[derive(Error, Debug)]
10pub enum ParseError {
11    #[error("{0}")]
12    Message(String),
13    // ethabi parser error
14    #[error(transparent)]
15    ParseError(#[from] ethabi::Error),
16    // errors from human readable lexer
17    #[error(transparent)]
18    LexerError(#[from] human_readable::lexer::LexerError),
19}
20
21macro_rules! _format_err {
22    ($($tt:tt)*) => {
23        $crate::abi::ParseError::Message(format!($($tt)*))
24    };
25}
26pub(crate) use _format_err as format_err;
27
28macro_rules! _bail {
29    ($($tt:tt)*) => { return Err($crate::abi::error::format_err!($($tt)*)) };
30}
31use crate::types::ParseBytesError;
32pub(crate) use _bail as bail;
33
34/// ABI codec related errors
35#[derive(Error, Debug)]
36pub enum AbiError {
37    /// Thrown when the ABI decoding fails
38    #[error(transparent)]
39    DecodingError(#[from] ethabi::Error),
40
41    /// Thrown when detokenizing an argument
42    #[error(transparent)]
43    DetokenizationError(#[from] InvalidOutputType),
44
45    #[error("missing or wrong function selector")]
46    WrongSelector,
47
48    #[error(transparent)]
49    ParseBytesError(#[from] ParseBytesError),
50}