Skip to main content

chainindex_core/
error.rs

1//! Error types for the chainindex pipeline.
2
3use thiserror::Error;
4
5/// Errors that can occur during indexing.
6#[derive(Debug, Error)]
7pub enum IndexerError {
8    #[error("RPC error: {0}")]
9    Rpc(String),
10
11    #[error("Storage error: {0}")]
12    Storage(String),
13
14    #[error("Handler error in '{handler}': {reason}")]
15    Handler { handler: String, reason: String },
16
17    #[error("Reorg detected at block {block_number}: expected hash {expected}, got {actual}")]
18    ReorgDetected {
19        block_number: u64,
20        expected: String,
21        actual: String,
22    },
23
24    #[error("Checkpoint mismatch at block {block_number}")]
25    CheckpointMismatch { block_number: u64 },
26
27    #[error("Indexer aborted: {reason}")]
28    Aborted { reason: String },
29
30    #[error("{0}")]
31    Other(String),
32}
33
34impl IndexerError {
35    /// Returns `true` if the error is a reorg (recoverable).
36    pub fn is_reorg(&self) -> bool {
37        matches!(self, Self::ReorgDetected { .. })
38    }
39}