Skip to main content

cdk_prometheus/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur in the Prometheus crate
4#[derive(Error, Debug)]
5pub enum PrometheusError {
6    /// Server binding error
7    #[error("Failed to bind to address {address}: {source}")]
8    ServerBind {
9        /// Address that failed to bind
10        address: String,
11        #[source]
12        /// Underlying I/O error
13        source: std::io::Error,
14    },
15
16    /// Metrics collection error
17    #[error("Failed to collect metrics: {0}")]
18    MetricsCollection(String),
19
20    /// Registry error
21    #[error("Registry error: {source}")]
22    Registry {
23        #[from]
24        /// Underlying Prometheus error
25        source: prometheus::Error,
26    },
27
28    /// System metrics error
29    #[cfg(feature = "system-metrics")]
30    #[error("System metrics error: {0}")]
31    SystemMetrics(String),
32}
33
34/// Result type for Prometheus operations
35pub type Result<T> = std::result::Result<T, PrometheusError>;