posemesh_domain_http/
errors.rs1use futures::channel::{mpsc::SendError, oneshot::Canceled};
2use reqwest::StatusCode;
3
4#[derive(Debug, thiserror::Error)]
5pub enum AuthError {
6 #[error("Invalid credentials: {0}")]
7 Unauthorized(&'static str),
8 #[error("Parse JWT token: base64 decode error: {0}")]
9 Base64DecodeError(#[from] base64::DecodeError),
10 #[error("JSON parse error: {0}")]
11 JsonParseError(#[from] serde_json::Error),
12}
13
14#[derive(Debug, Clone)]
15pub struct AukiErrorResponse {
16 pub status: StatusCode,
17 pub error: String,
18}
19
20impl std::fmt::Display for AukiErrorResponse {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 write!(f, "Auki response - status: {}, error: {}", self.status, self.error)
23 }
24}
25
26impl std::error::Error for AukiErrorResponse {}
27
28#[derive(Debug, thiserror::Error)]
29pub enum DomainError {
30 #[error("Reqwest error: {0}")]
31 ReqwestError(#[from] reqwest::Error),
32 #[error("{0}")]
33 AukiErrorResponse(#[from] AukiErrorResponse),
34 #[error("Invalid content-type header")]
35 InvalidContentTypeHeader,
36 #[error("Stream error: {0}")]
37 StreamError(#[from] SendError),
38 #[error("Stream cancelled: {0}")]
39 StreamCancelled(#[from] Canceled),
40 #[error("Auth error: {0}")]
41 AuthError(#[from] AuthError),
42 #[error("Invalid request: {0}")]
43 InvalidRequest(&'static str),
44}