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 std::error::Error as StdError;
use thiserror::Error;
use url::ParseError;
use crate::{client::Request, enums::RequestType};
#[derive(Error, Debug)]
pub enum ClientError {
#[error("Error parsing endpoint into data")]
DataParseError { source: Box<dyn StdError> },
#[error("Error building endpoint request")]
EndpointBuildError { source: Box<dyn StdError> },
#[error("An error occurred in processing the request")]
GenericError { source: Box<dyn StdError> },
#[error("Error sending HTTP request")]
RequestError {
source: Box<dyn StdError>,
request: Request,
},
#[error("Error building HTTP request")]
RequestBuildError {
source: Box<dyn StdError>,
method: RequestType,
url: String,
},
#[error("Error retrieving HTTP response")]
ResponseError { source: Box<dyn StdError> },
#[error("Error parsing server response as UTF-8")]
ResponseConversionError {
source: Box<dyn StdError>,
content: Vec<u8>,
},
#[error("Error parsing HTTP response")]
ResponseParseError {
source: Box<dyn StdError>,
content: String,
},
#[error("Server returned error")]
ServerResponseError {
url: String,
code: u16,
content: Option<String>,
},
#[error("Error parsing URL")]
UrlParseError { source: ParseError, url: String },
}