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
use crates::reqwest;
use crates::serde_json::Value;
error_chain! {
foreign_links {
Reqwest(reqwest::Error)
#[doc = "An error from the reqwest crate."];
}
errors {
Communication {
display("communication error")
}
UrlParse {
display("url error")
}
Gitlab(msg: String) {
display("gitlab error: {}", msg)
}
Deserialize {
display("deserialization error")
}
}
}
impl Error {
pub fn from_gitlab(value: Value) -> Self {
let msg = value.pointer("/message")
.and_then(|s| s.as_str())
.unwrap_or_else(|| "unknown error");
Error::from_kind(ErrorKind::Gitlab(msg.to_string()))
}
}