Skip to main content

smith_logging/
error.rs

1//! Error types for Smith logging infrastructure
2
3use thiserror::Error;
4
5/// Result type for logging operations
6pub type LoggingResult<T> = Result<T, LoggingError>;
7
8/// Errors that can occur in the logging infrastructure
9#[derive(Error, Debug)]
10pub enum LoggingError {
11    /// NATS connection or publish error
12    #[error("NATS error: {0}")]
13    Nats(#[from] async_nats::Error),
14
15    /// Serialization error
16    #[error("Serialization error: {0}")]
17    Serialization(#[from] serde_json::Error),
18
19    /// Configuration error
20    #[error("Configuration error: {0}")]
21    Config(String),
22
23    /// Rate limit exceeded
24    #[error("Rate limit exceeded")]
25    RateLimitExceeded,
26
27    /// Buffer overflow
28    #[error("Log buffer overflow")]
29    BufferOverflow,
30
31    /// Timeout error
32    #[error("Operation timed out")]
33    Timeout,
34
35    /// Generic error
36    #[error("Logging error: {0}")]
37    Generic(String),
38}
39
40impl From<&str> for LoggingError {
41    fn from(s: &str) -> Self {
42        LoggingError::Generic(s.to_string())
43    }
44}
45
46impl From<String> for LoggingError {
47    fn from(s: String) -> Self {
48        LoggingError::Generic(s)
49    }
50}