Skip to main content

astrid_audit/
error.rs

1//! Audit-related error types.
2
3use thiserror::Error;
4
5/// Errors that can occur with audit logging.
6#[derive(Debug, Error)]
7pub enum AuditError {
8    /// Storage error.
9    #[error("storage error: {0}")]
10    StorageError(String),
11
12    /// Serialization error.
13    #[error("serialization error: {0}")]
14    SerializationError(String),
15
16    /// Entry not found.
17    #[error("audit entry not found: {entry_id}")]
18    EntryNotFound {
19        /// The entry ID that was not found.
20        entry_id: String,
21    },
22
23    /// Chain integrity violation.
24    #[error("chain integrity violation at entry {entry_id}: {reason}")]
25    IntegrityViolation {
26        /// The entry where violation was detected.
27        entry_id: String,
28        /// Why the chain is invalid.
29        reason: String,
30    },
31
32    /// Invalid signature on entry.
33    #[error("invalid signature on entry {entry_id}")]
34    InvalidSignature {
35        /// The entry with invalid signature.
36        entry_id: String,
37    },
38
39    /// Session not found.
40    #[error("session not found: {session_id}")]
41    SessionNotFound {
42        /// The session ID that was not found.
43        session_id: String,
44    },
45
46    /// Crypto error.
47    #[error("crypto error: {0}")]
48    CryptoError(#[from] astrid_crypto::CryptoError),
49}
50
51/// Result type for audit operations.
52pub type AuditResult<T> = Result<T, AuditError>;