Skip to main content

ethrex_storage/
error.rs

1use ethrex_rlp::error::RLPDecodeError;
2use ethrex_trie::TrieError;
3use thiserror::Error;
4
5// TODO improve errors
6#[derive(Debug, Error)]
7pub enum StoreError {
8    #[error("DecodeError")]
9    DecodeError,
10    #[cfg(feature = "rocksdb")]
11    #[error("Rocksdb error: {0}")]
12    RocksdbError(#[from] rocksdb::Error),
13    #[error("{0}")]
14    Custom(String),
15    #[error(transparent)]
16    RLPDecode(#[from] RLPDecodeError),
17    #[error(transparent)]
18    Trie(#[from] TrieError),
19    #[error("missing store: is an execution DB being used instead?")]
20    MissingStore,
21    #[error("Could not open DB for reading")]
22    ReadError,
23    #[error("Could not instantiate cursor for table {0}")]
24    CursorError(String),
25    #[error("Missing latest block number")]
26    MissingLatestBlockNumber,
27    #[error("Missing earliest block number")]
28    MissingEarliestBlockNumber,
29    #[error("Failed to lock mempool for writing")]
30    MempoolWriteLock(String),
31    #[error("Failed to lock mempool for reading")]
32    MempoolReadLock(String),
33    #[error("Failed to lock database for writing")]
34    LockError,
35    #[error("Incompatible chain configuration")]
36    IncompatibleChainConfig,
37    #[error("Failed to convert index: {0}")]
38    TryInto(#[from] std::num::TryFromIntError),
39    #[error("Update batch contains no blocks")]
40    UpdateBatchNoBlocks,
41    #[error("Pivot changed")]
42    PivotChanged,
43    #[error("Error reading from disk: {0}")]
44    IoError(#[from] std::io::Error),
45    #[error("Error serializing metadata: {0}")]
46    DbMetadataError(#[from] serde_json::Error),
47    #[error(
48        "Cannot migrate the database: its version is unavailable, which means it predates versioning and migrations. A full resync (removedb) is required."
49    )]
50    NotFoundDBVersion,
51    #[error("Incompatible DB Version: found v{found}, expected v{expected}")]
52    IncompatibleDBVersion { found: u64, expected: u64 },
53    #[error("Migration from v{from} to v{to} failed: {reason}")]
54    MigrationFailed { from: u64, to: u64, reason: String },
55}