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
use std::fmt::Debug;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("internal error: {msg}")]
InternalError { msg: &'static str },
#[error("resolver failed")]
ResolverError {
#[from]
source: crate::resolver::Error,
},
#[error("external service failed")]
ServiceError {
#[from]
source: crate::services::Error,
},
#[error("failed to parse '{what}' to {to} because {why}")]
ParserError {
what: String,
to: &'static str,
why: String,
},
#[error("failed to execute IO operation for")]
IoError {
#[from]
source: std::io::Error,
},
#[error("failed to serialize to JSON")]
SerJsonError {
#[from]
source: serde_json::Error,
},
}
pub trait Errors {
fn errors(&self) -> Box<dyn Iterator<Item = Box<&dyn std::error::Error>> + '_>;
}