1use thiserror::Error;
3
4use crate::enums::RequestMethod;
5
6#[derive(Error, Debug)]
8pub enum ClientError {
9 #[error("Error parsing endpoint into data")]
10 DataParseError { source: anyhow::Error },
11 #[error("Error building endpoint request")]
12 EndpointBuildError { source: anyhow::Error },
13 #[error("An error occurred in processing the request")]
14 GenericError { source: anyhow::Error },
15 #[error("Error sending HTTP request")]
16 RequestError {
17 source: anyhow::Error,
18 url: String,
19 method: String,
20 },
21 #[error("Error building HTTP request")]
22 RequestBuildError {
23 source: http::Error,
24 method: RequestMethod,
25 url: String,
26 },
27 #[error("Error building request for Reqwest crate")]
28 ReqwestBuildError { source: reqwest::Error },
29 #[error("Error retrieving HTTP response")]
30 ResponseError { source: anyhow::Error },
31 #[error("Error parsing server response as UTF-8")]
32 ResponseConversionError {
33 source: anyhow::Error,
34 content: Vec<u8>,
35 },
36 #[error("Error parsing HTTP response")]
37 ResponseParseError {
38 source: anyhow::Error,
39 content: Option<String>,
40 },
41 #[error("Server returned error")]
42 ServerResponseError { code: u16, content: Option<String> },
43 #[error("Error building URL")]
44 UrlBuildError { source: http::uri::InvalidUri },
45 #[error("Error serializing URL query parameters")]
46 UrlQueryParseError { source: anyhow::Error },
47 #[error("Error parsing URL")]
48 UrlParseError { source: url::ParseError },
49}