use std::io;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, MetricsError>;
#[derive(Error, Debug)]
pub enum MetricsError {
#[error("I/O error: {0}")]
IoError(#[from] io::Error),
#[error("Invalid metric value: {0}")]
InvalidValue(String),
#[error("Invalid metric name: {0}")]
InvalidName(String),
#[error("Invalid label: {0}")]
InvalidLabel(String),
#[error("Path configuration error: {0}")]
PathError(String),
#[error("Serialization error: {0}")]
SerializationError(String),
#[error("Operation failed: {0}")]
Other(String),
}
impl From<String> for MetricsError {
fn from(err: String) -> Self {
MetricsError::Other(err)
}
}
impl From<&str> for MetricsError {
fn from(err: &str) -> Self {
MetricsError::Other(err.to_string())
}
}