use reqwest::StatusCode;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ClientError {
#[error("the resource lookup returned an empty HTTP {http_status} response")]
EmptyNotFound { http_status: StatusCode },
#[error("failed to initialize the HTTP client")]
Build(#[source] reqwest::Error),
#[error("the request could not be completed")]
Transport(#[source] reqwest::Error),
#[error("the server returned an unexpected redirect ({status})")]
UnexpectedRedirect { status: StatusCode },
#[error("the server response exceeded the {limit_bytes}-byte limit")]
ResponseTooLarge {
limit_bytes: usize,
status: StatusCode,
retry_after_seconds: Option<u64>,
},
#[error("the server response body could not be read")]
ResponseBody {
status: StatusCode,
retry_after_seconds: Option<u64>,
#[source]
source: reqwest::Error,
},
#[error("the server returned an invalid response: {message}")]
Protocol {
message: String,
diagnostic: Option<super::ResponseDiagnostic>,
success_status_received: bool,
},
#[error(
"the Wekan server returned an embedded error without statusCode in an HTTP {http_status} response"
)]
EmbeddedProtocol {
http_status: StatusCode,
server_error: Option<String>,
server_reason: Option<String>,
server_message: Option<String>,
server_error_type: Option<String>,
server_is_client_safe: Option<bool>,
},
#[error("the Wekan server returned an error ({status})")]
Server {
status: StatusCode,
server_error: Option<String>,
server_reason: Option<String>,
retry_after_seconds: Option<u64>,
},
#[error(
"the Wekan server returned an embedded error ({wekan_status_code}) in an HTTP {http_status} response"
)]
EmbeddedServer {
http_status: StatusCode,
wekan_status_code: u16,
server_error: Option<String>,
server_reason: Option<String>,
},
}