chronix_security/audit/error.rs
1//! Error types for the audit logging system.
2
3use thiserror::Error;
4
5/// Errors that can occur in the audit logging system.
6#[derive(Debug, Error)]
7pub enum AuditError {
8 /// I/O error (file-based sink).
9 #[error("Audit I/O error: {0}")]
10 Io(#[from] std::io::Error),
11 /// Serialization error.
12 #[error("Audit serialization error: {0}")]
13 Serialization(String),
14 /// Configuration error.
15 #[error("Audit config error: {0}")]
16 Config(String),
17 /// Internal error.
18 #[error("Audit internal error: {0}")]
19 Internal(String),
20 /// Partial delivery — some sinks succeeded, others failed.
21 ///
22 /// Returned by strict audit logging when at least one sink fails.
23 /// Contains the list of failures so the caller can decide how to
24 /// handle the incomplete audit trail.
25 #[error(
26 "Audit partial delivery: {succeeded} of {total} sinks succeeded, failures: {failures:?}"
27 )]
28 PartialDelivery {
29 /// Number of sinks that succeeded.
30 succeeded: usize,
31 /// Total number of sinks attempted.
32 total: usize,
33 /// Sink name and error message for each failure.
34 failures: Vec<(String, String)>,
35 },
36 /// No durable sink configured — audit events will be lost
37 /// on process restart.
38 #[error("No durable audit sink configured — compliance violation")]
39 NoDurableSink,
40}
41
42/// Result alias for audit operations.
43pub type Result<T> = std::result::Result<T, AuditError>;