1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use combine::error::StringStreamError;
use std::{io, str};
#[derive(Debug)]
pub enum LustreCollectorError {
IoError(io::Error),
SerdeJsonError(serde_json::error::Error),
SerdeYamlError(serde_yaml::Error),
StringStreamError(StringStreamError),
CombineEasyError(combine::stream::easy::Errors<char, &'static str, usize>),
Utf8Error(str::Utf8Error),
}
impl std::fmt::Display for LustreCollectorError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
LustreCollectorError::IoError(ref err) => write!(f, "{}", err),
LustreCollectorError::SerdeJsonError(ref err) => write!(f, "{}", err),
LustreCollectorError::SerdeYamlError(ref err) => write!(f, "{}", err),
LustreCollectorError::StringStreamError(ref err) => write!(f, "{}", err),
LustreCollectorError::CombineEasyError(ref err) => write!(f, "{}", err),
LustreCollectorError::Utf8Error(ref err) => write!(f, "{}", err),
}
}
}
impl std::error::Error for LustreCollectorError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match *self {
LustreCollectorError::IoError(ref err) => Some(err),
LustreCollectorError::SerdeJsonError(ref err) => Some(err),
LustreCollectorError::SerdeYamlError(ref err) => Some(err),
LustreCollectorError::StringStreamError(ref err) => Some(err),
LustreCollectorError::Utf8Error(ref err) => Some(err),
LustreCollectorError::CombineEasyError(ref err) => Some(err),
}
}
}
impl From<serde_json::error::Error> for LustreCollectorError {
fn from(err: serde_json::error::Error) -> Self {
LustreCollectorError::SerdeJsonError(err)
}
}
impl From<serde_yaml::Error> for LustreCollectorError {
fn from(err: serde_yaml::Error) -> Self {
LustreCollectorError::SerdeYamlError(err)
}
}
impl From<io::Error> for LustreCollectorError {
fn from(err: io::Error) -> Self {
LustreCollectorError::IoError(err)
}
}
impl From<str::Utf8Error> for LustreCollectorError {
fn from(err: str::Utf8Error) -> Self {
LustreCollectorError::Utf8Error(err)
}
}
impl From<StringStreamError> for LustreCollectorError {
fn from(err: StringStreamError) -> Self {
LustreCollectorError::StringStreamError(err)
}
}
impl From<combine::stream::easy::Errors<char, &str, usize>> for LustreCollectorError {
fn from(err: combine::stream::easy::Errors<char, &str, usize>) -> Self {
LustreCollectorError::CombineEasyError(err.map_range(|_| ""))
}
}