kaspa_metrics_core/
error.rs

1use kaspa_rpc_core::RpcError;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum Error {
6    #[error("{0}")]
7    Custom(String),
8
9    #[error("Missing metrics data `{0}`")]
10    MissingData(&'static str),
11
12    #[error(transparent)]
13    RpcError(#[from] RpcError),
14}
15
16impl Error {
17    pub fn custom<T: Into<String>>(msg: T) -> Self {
18        Error::Custom(msg.into())
19    }
20}
21
22impl From<String> for Error {
23    fn from(err: String) -> Self {
24        Self::Custom(err)
25    }
26}
27
28impl From<&str> for Error {
29    fn from(err: &str) -> Self {
30        Self::Custom(err.to_string())
31    }
32}