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
use std::error::Error as StdError;
use std::fmt;
pub mod reqwest {
pub use reqwest::Error;
pub use reqwest::Response;
}
use ::reqwest::*;
pub type Result<T> = std::result::Result<T, RiotApiError>;
#[derive(Debug)]
pub struct RiotApiError {
reqwest_error: Error,
retries: u8,
response: Option<Response>,
}
impl RiotApiError {
pub fn new(reqwest_error: Error, retries: u8, response: Option<Response>) -> Self {
Self {
reqwest_error: reqwest_error,
retries: retries,
response: response,
}
}
pub fn source_reqwest_error(&self) -> &Error {
&self.reqwest_error
}
pub fn retries(&self) -> u8 {
self.retries
}
pub fn response<'a>(&self) -> Option<&Response> {
self.response.as_ref()
}
}
impl fmt::Display for RiotApiError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:#?}", self)
}
}
impl StdError for RiotApiError {
fn source(&self) -> Option<&(dyn StdError + 'static)> {
Some(&self.reqwest_error)
}
}