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
#[derive(Debug, Clone)]
#[non_exhaustive]
pub enum Error {
SourceParse(String),
ParameterParse(String, String),
WrongMethodParameters,
WrongConfig,
InvalidCandles,
Other(String),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::SourceParse(value) => write!(f, "Unable to parse value as Source: {:?}", value),
Self::ParameterParse(name, value) => {
write!(f, "Unable to parse into {}: {:?}", name, value)
}
Self::WrongMethodParameters => write!(f, "Wrong method parameters"),
Self::WrongConfig => write!(f, "Wrong config"),
Self::InvalidCandles => write!(f, "Invalid candles"),
Self::Other(reason) => write!(f, "{}", reason),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
None
}
}