Skip to main content

dr_metrix_core/
error.rs

1pub type Result<T> = std::result::Result<T, MetricsError>;
2
3#[derive(Debug, thiserror::Error)]
4pub enum MetricsError {
5    #[error("prometheus error: {0}")]
6    Prometheus(#[from] prometheus::Error),
7    #[error("database error: {0}")]
8    Database(String),
9    #[error("collector error: {0}")]
10    Collector(String),
11}
12
13impl MetricsError {
14    pub fn database(msg: impl std::fmt::Display) -> Self {
15        Self::Database(msg.to_string())
16    }
17    pub fn collector(msg: impl std::fmt::Display) -> Self {
18        Self::Collector(msg.to_string())
19    }
20}