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
use serde::Deserialize;
use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Deserialize, Debug, Clone)]
pub struct ErrorResponse {
pub request_id: String,
pub error_type: String,
pub error_code: String,
pub error_message: String,
pub display_message: Option<String>,
}
#[derive(Debug, Clone)]
pub struct Error {
pub error_type: String,
pub error_code: String,
pub error_message: String,
pub display_message: Option<String>,
pub request_id: String,
pub status_code: reqwest::StatusCode,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"Plaid Error - request ID: {}, http status: {}, type: {}, code: {}, message: {}, display_message: {}",
self.request_id,
self.status_code,
self.error_type,
self.error_code,
self.error_message,
self.display_message.as_ref().unwrap_or(&"".to_string()),
)
}
}