textfile_metrics/
errors.rs1use std::io;
7
8use thiserror::Error;
9
10pub type Result<T> = std::result::Result<T, MetricsError>;
12
13#[derive(Error, Debug)]
15pub enum MetricsError {
16 #[error("I/O error: {0}")]
18 IoError(#[from] io::Error),
19
20 #[error("Invalid metric value: {0}")]
22 InvalidValue(String),
23
24 #[error("Invalid metric name: {0}")]
26 InvalidName(String),
27
28 #[error("Invalid label: {0}")]
30 InvalidLabel(String),
31
32 #[error("Path configuration error: {0}")]
34 PathError(String),
35
36 #[error("Serialization error: {0}")]
38 SerializationError(String),
39
40 #[error("Operation failed: {0}")]
42 Other(String),
43}
44
45impl From<String> for MetricsError {
46 fn from(err: String) -> Self {
47 MetricsError::Other(err)
48 }
49}
50
51impl From<&str> for MetricsError {
52 fn from(err: &str) -> Self {
53 MetricsError::Other(err.to_string())
54 }
55}