1use alloy_primitives::{Address, U256};
5use revm::primitives::EVMError;
6use revm::primitives::B256;
7use thiserror::Error;
8
9use std::convert::Infallible;
10
11#[derive(Error, Debug)]
13pub enum DatabaseError {
14 #[error("missing AccountInfo {0}")]
15 MissingAccount(Address),
16 #[error("code should already be loaded: {0}")]
17 MissingCode(B256),
18 #[error("failed to get account for {0}")]
19 GetAccount(Address),
20 #[error("failed to get storage for {0} at {1}")]
21 GetStorage(Address, U256),
22 #[error("failed to get block hash for {0}")]
23 GetBlockHash(U256),
24 #[error("{0}")]
25 Other(String),
26}
27
28impl From<EVMError<DatabaseError>> for DatabaseError {
29 fn from(err: EVMError<DatabaseError>) -> Self {
30 match err {
31 EVMError::Database(err) => err,
32 err => DatabaseError::Other(err.to_string()),
33 }
34 }
35}
36
37impl From<Infallible> for DatabaseError {
38 fn from(value: Infallible) -> Self {
39 match value {}
40 }
41}