Skip to main content

wekan_cli/client/
error.rs

1use reqwest::StatusCode;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum ClientError {
6    #[error("failed to initialize the HTTP client")]
7    Build(#[source] reqwest::Error),
8    #[error("the request could not be completed")]
9    Transport(#[source] reqwest::Error),
10    #[error("the server returned an unexpected redirect ({status})")]
11    UnexpectedRedirect { status: StatusCode },
12    #[error("the server response exceeded the {limit_bytes}-byte limit")]
13    ResponseTooLarge {
14        limit_bytes: usize,
15        status: StatusCode,
16        retry_after_seconds: Option<u64>,
17    },
18    #[error("the server response body could not be read")]
19    ResponseBody {
20        status: StatusCode,
21        retry_after_seconds: Option<u64>,
22        #[source]
23        source: reqwest::Error,
24    },
25    #[error("the server returned an invalid response: {message}")]
26    Protocol {
27        message: String,
28        success_status_received: bool,
29    },
30    #[error(
31        "the Wekan server returned an embedded error without statusCode in an HTTP {http_status} response"
32    )]
33    EmbeddedProtocol {
34        http_status: StatusCode,
35        server_error: Option<String>,
36        server_reason: Option<String>,
37        server_message: Option<String>,
38        server_error_type: Option<String>,
39        server_is_client_safe: Option<bool>,
40    },
41    #[error("the Wekan server returned an error ({status})")]
42    Server {
43        status: StatusCode,
44        server_error: Option<String>,
45        server_reason: Option<String>,
46        retry_after_seconds: Option<u64>,
47    },
48    #[error(
49        "the Wekan server returned an embedded error ({wekan_status_code}) in an HTTP {http_status} response"
50    )]
51    EmbeddedServer {
52        http_status: StatusCode,
53        wekan_status_code: u16,
54        server_error: Option<String>,
55        server_reason: Option<String>,
56    },
57}