use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum EvmError {
#[error("Failed to initialize EVM: {0}")]
Init(#[from] InitError),
#[error("Error during execution: {0}")]
Runtime(#[from] RuntimeError),
#[error("Token error: {0}")]
Token(#[from] TokenError),
#[error("Override error: {0}")]
OverrideError(String),
}
#[derive(Debug, Clone, Error)]
pub enum InitError {
#[error("Invalid RPC URL: {0}")]
InvalidRpcUrl(String),
#[error("Database initialization failed: {0}")]
DatabaseError(String),
#[error("WebSocket connection failed: {0}")]
WsConnection(String),
#[error("Failed to get chain ID: {0}")]
ChainId(String),
#[error("Failed to fetch chain ID: {0}")]
ChainIdFetchError(String),
#[error("Failed to fetch block: {0}")]
BlockFetchError(String),
#[error("Block not found: {0}")]
BlockNotFound(String),
}
#[derive(Debug, Clone, Error)]
pub enum RuntimeError {
#[error("Transaction execution failed: {0}")]
ExecutionFailed(String),
#[error("Account access error: {0}")]
AccountAccess(String),
#[error("Slot access error: {0}")]
SlotAccess(String),
#[error("Out of gas")]
OutOfGas,
#[error("Reverted: {0}")]
Revert(String),
#[error("Reverted due to insufficient balance: {0}")]
NoTokioRuntime(String),
#[error("Failed to decode data: {0}")]
DecodeError(String),
}
#[derive(Debug, Error)]
pub enum BalanceError {
#[error("Failed to decode balance for {holder} in token {address}: {reason}")]
BalanceDecode {
address: String,
holder: String,
reason: String,
},
#[error("Failed to get balance of {holder}: {reason}")]
BalanceGetError { holder: String, reason: String },
}
#[derive(Debug, Clone, Error)]
pub enum TokenError {
#[error("Token error: {0}")]
AnyhowError(String),
#[error("Failed to decode token name for {address}: {reason}")]
NameDecode { address: String, reason: String },
#[error("Failed to decode token symbol for {address}: {reason}")]
SymbolDecode { address: String, reason: String },
#[error("Failed to decode token decimals for {address}: {reason}")]
DecimalsDecode { address: String, reason: String },
#[error("Failed to decode token total supply for {address}: {reason}")]
TotalSupplyDecode { address: String, reason: String },
#[error("Failed to decode balance for {holder} in token {address}: {reason}")]
BalanceDecode {
address: String,
holder: String,
reason: String,
},
#[error("Failed to query token {address}: {reason}")]
QueryFailed { address: String, reason: String },
#[error("Token call reverted for {address}")]
CallReverted { address: String },
}