use thiserror::Error;
#[derive(Debug, Error)]
pub enum AuditError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Configuration error: {0}")]
Config(String),
#[error("Audit buffer full, events may be dropped")]
BufferFull,
#[error("Audit logger not initialized")]
NotInitialized,
#[error("Multiple errors: {0:?}")]
Multiple(Vec<String>),
#[error("Log rotation error: {0}")]
Rotation(String),
#[error("Channel send error")]
ChannelSend,
#[error("Logger shutdown error: {0}")]
Shutdown(String),
#[error("Internal error: {0}")]
Internal(String),
}
impl AuditError {
pub fn config(msg: impl Into<String>) -> Self {
Self::Config(msg.into())
}
pub fn rotation(msg: impl Into<String>) -> Self {
Self::Rotation(msg.into())
}
pub fn internal(msg: impl Into<String>) -> Self {
Self::Internal(msg.into())
}
}