Skip to main content

zots_core/
error.rs

1//! Error types for zots-core
2
3use thiserror::Error;
4
5/// Core errors for zOpenTimestamps operations
6#[derive(Error, Debug)]
7pub enum Error {
8    /// IO error during file operations
9    #[error("IO error: {0}")]
10    Io(#[from] std::io::Error),
11
12    /// Invalid proof format or corrupted proof file
13    #[error("Invalid proof format: {0}")]
14    InvalidProof(String),
15
16    /// Hash mismatch during verification
17    #[error("Hash mismatch: expected {expected}, got {actual}")]
18    HashMismatch { expected: String, actual: String },
19
20    /// Invalid hash format (wrong length or non-hex characters)
21    #[error("Invalid hash format: {0}")]
22    InvalidHash(String),
23
24    /// Proof not yet confirmed on blockchain
25    #[error("Proof not yet confirmed")]
26    NotConfirmed,
27
28    /// Transaction not found on blockchain
29    #[error("Transaction not found: {0}")]
30    TxNotFound(String),
31
32    /// Network communication error
33    #[error("Network error: {0}")]
34    Network(String),
35}
36
37/// Result type alias for zots-core operations
38pub type Result<T> = std::result::Result<T, Error>;