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
79
80
81
82
83
84
85
86
87
88
89
90
use failure::Fail;
#[derive(Debug, Fail)]
pub enum Error {
#[fail(display = "Error making HTTP Request: {}", _0)]
ReqwestError(#[cause] reqwest::Error),
#[fail(display = "Error parsing HTTP header: {}", _0)]
HeadersErrors(#[cause] reqwest::header::ToStrError),
#[fail(display = "Error Parsing URL: {}", _0)]
UrlParseError(#[cause] url::ParseError),
#[fail(display = "Unexpected response from Vault: {}", _0)]
InvalidVaultResponse(String),
#[fail(display = "Error parsing integer: {}", _0)]
ParseIntError(#[cause] std::num::ParseIntError),
#[fail(display = "Error deserializing JSON: {}", _0)]
JsonError(#[cause] serde_json::Error),
#[fail(display = "Vault Address is missing")]
MissingAddress,
#[fail(display = "Vault Token is missing")]
MissingToken,
#[fail(display = "{}", _0)]
IoError(#[cause] std::io::Error),
#[fail(display = "Error converting bytes to UTF-8: {}", _0)]
Utf8Error(#[cause] std::string::FromUtf8Error),
#[fail(display = "Vault Error: {}", _0)]
VaultError(String),
#[fail(display = "Expected data from Vault, but was missing: {:#?}", _0)]
MissingData(Box<crate::Response>),
#[fail(display = "Expected an empty response from Vault but got {}", _0)]
UnexpectedResponse(String),
#[fail(display = "Response from Vault was not in the expected form")]
MalformedResponse,
}
impl From<reqwest::Error> for Error {
fn from(error: reqwest::Error) -> Self {
Error::ReqwestError(error)
}
}
impl From<reqwest::header::ToStrError> for Error {
fn from(error: reqwest::header::ToStrError) -> Self {
Error::HeadersErrors(error)
}
}
impl From<url::ParseError> for Error {
fn from(error: url::ParseError) -> Self {
Error::UrlParseError(error)
}
}
impl From<std::num::ParseIntError> for Error {
fn from(error: std::num::ParseIntError) -> Self {
Error::ParseIntError(error)
}
}
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
Error::JsonError(error)
}
}
impl From<std::io::Error> for Error {
fn from(error: std::io::Error) -> Self {
Error::IoError(error)
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(error: std::string::FromUtf8Error) -> Self {
Error::Utf8Error(error)
}
}