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!(
23 f,
24 "Auki response - status: {}, error: {}",
25 self.status, self.error
26 )
27 }
28}
29
30impl std::error::Error for AukiErrorResponse {}
31
32#[derive(Debug, thiserror::Error)]
33pub enum DomainError {
34 #[error("Reqwest error: {0}")]
35 ReqwestError(#[from] reqwest::Error),
36 #[error("{0}")]
37 AukiErrorResponse(#[from] AukiErrorResponse),
38 #[error("Invalid content-type header")]
39 InvalidContentTypeHeader,
40 #[error("Stream error: {0}")]
41 StreamError(#[from] SendError),
42 #[error("Stream cancelled: {0}")]
43 StreamCancelled(#[from] Canceled),
44 #[error("Auth error: {0}")]
45 AuthError(#[from] AuthError),
46 #[error("Invalid request: {0}")]
47 InvalidRequest(&'static str),
48}