Skip to main content

eggress_embed/
error.rs

1/// Stable error type for the embed API.
2///
3/// All variants carry string messages with credentials redacted.
4/// The variants are designed for stable PyO3 mapping in later phases.
5#[derive(Debug, thiserror::Error)]
6pub enum EggressError {
7    /// Configuration parsing or validation error.
8    #[error("config error: {0}")]
9    Config(String),
10
11    /// Runtime initialization error.
12    #[error("runtime error: {0}")]
13    Runtime(String),
14
15    /// Service startup error.
16    #[error("startup error: {0}")]
17    Startup(String),
18
19    /// Configuration reload error.
20    #[error("reload error: {0}")]
21    Reload(String),
22
23    /// Shutdown error.
24    #[error("shutdown error: {0}")]
25    Shutdown(String),
26
27    /// Attempted to use a feature not supported by the embed API.
28    #[error("unsupported feature: {feature}: {message}")]
29    UnsupportedFeature {
30        /// Feature name.
31        feature: String,
32        /// Human-readable explanation.
33        message: String,
34    },
35
36    /// Internal error (should not occur in normal usage).
37    #[error("internal error: {0}")]
38    Internal(String),
39}
40
41impl EggressError {
42    /// Return a short category label for the error.
43    pub fn category(&self) -> &'static str {
44        match self {
45            EggressError::Config(_) => "config",
46            EggressError::Runtime(_) => "runtime",
47            EggressError::Startup(_) => "startup",
48            EggressError::Reload(_) => "reload",
49            EggressError::Shutdown(_) => "shutdown",
50            EggressError::UnsupportedFeature { .. } => "unsupported_feature",
51            EggressError::Internal(_) => "internal",
52        }
53    }
54}