Skip to main content

aex_audit/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum AuditError {
5    #[error("I/O error: {0}")]
6    Io(#[from] std::io::Error),
7
8    #[error("serialization error: {0}")]
9    Serialization(#[from] serde_json::Error),
10
11    #[error("chain broken at position {position}: expected prev_hash {expected}, found {found}")]
12    ChainBroken {
13        position: u64,
14        expected: String,
15        found: String,
16    },
17
18    #[error("hash mismatch at position {position}: stored {stored}, recomputed {recomputed}")]
19    HashMismatch {
20        position: u64,
21        stored: String,
22        recomputed: String,
23    },
24
25    #[error("invalid event: {0}")]
26    InvalidEvent(String),
27}
28
29pub type AuditResult<T> = Result<T, AuditError>;