1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum AuditError {
8 #[error("I/O error: {0}")]
10 Io(#[from] std::io::Error),
11
12 #[error("Serialization error: {0}")]
14 Serialization(#[from] serde_json::Error),
15
16 #[error("Configuration error: {0}")]
18 Config(String),
19
20 #[error("Audit buffer full, events may be dropped")]
22 BufferFull,
23
24 #[error("Audit logger not initialized")]
26 NotInitialized,
27
28 #[error("Multiple errors: {0:?}")]
30 Multiple(Vec<String>),
31
32 #[error("Log rotation error: {0}")]
34 Rotation(String),
35
36 #[error("Channel send error")]
38 ChannelSend,
39
40 #[error("Logger shutdown error: {0}")]
42 Shutdown(String),
43
44 #[error("Internal error: {0}")]
46 Internal(String),
47}
48
49impl AuditError {
50 pub fn config(msg: impl Into<String>) -> Self {
52 Self::Config(msg.into())
53 }
54
55 pub fn rotation(msg: impl Into<String>) -> Self {
57 Self::Rotation(msg.into())
58 }
59
60 pub fn internal(msg: impl Into<String>) -> Self {
62 Self::Internal(msg.into())
63 }
64}