mega_evme/common/
error.rs1use alloy_primitives::{hex::FromHexError, BlockNumber, TxHash, B256};
2use alloy_provider::transport::TransportError;
3use mega_evm::{alloy_evm::block::BlockExecutionError, revm::bytecode::BytecodeDecodeError};
4
5#[derive(Debug, thiserror::Error)]
7pub enum EvmeError {
8 #[error("RPC transport error: {0}")]
10 RpcTransportError(TransportError),
11
12 #[error("Transaction not found: {0}")]
14 TransactionNotFound(TxHash),
15
16 #[error("Block not found: {0}")]
18 BlockNotFound(BlockNumber),
19
20 #[error("Block execution error: {0}")]
22 BlockExecutionError(#[from] BlockExecutionError),
23
24 #[error("Invalid bytecode: {0}")]
26 InvalidBytecode(#[from] BytecodeDecodeError),
27
28 #[error("Failed to read file: {0}")]
30 FileRead(#[from] std::io::Error),
31
32 #[error("Invalid hex string: {0}")]
34 InvalidHex(#[from] FromHexError),
35
36 #[error("EVM execution error: {0}")]
38 ExecutionError(String),
39
40 #[error("Invalid input: {0}")]
42 InvalidInput(String),
43
44 #[error("RPC error: {0}")]
46 RpcError(String),
47
48 #[error("Fixture error: {0}")]
50 FixtureError(String),
51
52 #[error("Unsupported transaction type: {0}")]
54 UnsupportedTxType(u8),
55
56 #[error("Code hash mismatch: expected {expected}, computed {computed}")]
58 CodeHashMismatch {
59 expected: B256,
61 computed: B256,
63 },
64
65 #[error("Other error: {0}")]
67 Other(String),
68}
69
70impl mega_evm::revm::database::DBErrorMarker for EvmeError {}
72
73pub type Result<T> = std::result::Result<T, EvmeError>;