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        diagnostic: Option<super::ResponseDiagnostic>,
29        success_status_received: bool,
30    },
31    #[error(
32        "the Wekan server returned an embedded error without statusCode in an HTTP {http_status} response"
33    )]
34    EmbeddedProtocol {
35        http_status: StatusCode,
36        server_error: Option<String>,
37        server_reason: Option<String>,
38        server_message: Option<String>,
39        server_error_type: Option<String>,
40        server_is_client_safe: Option<bool>,
41    },
42    #[error("the Wekan server returned an error ({status})")]
43    Server {
44        status: StatusCode,
45        server_error: Option<String>,
46        server_reason: Option<String>,
47        retry_after_seconds: Option<u64>,
48    },
49    #[error(
50        "the Wekan server returned an embedded error ({wekan_status_code}) in an HTTP {http_status} response"
51    )]
52    EmbeddedServer {
53        http_status: StatusCode,
54        wekan_status_code: u16,
55        server_error: Option<String>,
56        server_reason: Option<String>,
57    },
58}