2023-10-27 22:48:40 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, thiserror::Error)]
|
2023-05-14 20:58:00 +00:00
|
|
|
pub enum Error {
|
|
|
|
#[error("HTTP Digest generation error")]
|
|
|
|
Digest,
|
|
|
|
#[error("JSON encoding error")]
|
2023-10-27 22:48:40 +00:00
|
|
|
Json(#[from] Arc<serde_json::Error>),
|
2023-05-14 20:58:00 +00:00
|
|
|
#[error("Signature error")]
|
2023-10-27 22:48:40 +00:00
|
|
|
Signature(#[from] Arc<sigh::Error>),
|
2023-05-14 21:14:55 +00:00
|
|
|
#[error("Signature verification failure")]
|
2023-10-29 23:28:56 +00:00
|
|
|
SignatureFail(String),
|
2023-05-14 20:58:00 +00:00
|
|
|
#[error("HTTP request error")]
|
2023-10-27 22:48:40 +00:00
|
|
|
HttpReq(#[from] Arc<http::Error>),
|
2023-05-14 20:58:00 +00:00
|
|
|
#[error("HTTP client error")]
|
2023-10-27 22:48:40 +00:00
|
|
|
Http(#[from] Arc<reqwest::Error>),
|
2023-05-14 20:58:00 +00:00
|
|
|
#[error("Invalid URI")]
|
|
|
|
InvalidUri,
|
|
|
|
#[error("Error response from remote")]
|
|
|
|
Response(String),
|
|
|
|
}
|
2023-10-27 22:48:40 +00:00
|
|
|
|
|
|
|
impl From<serde_json::Error> for Error {
|
|
|
|
fn from(e: serde_json::Error) -> Self {
|
|
|
|
Error::Json(Arc::new(e))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<reqwest::Error> for Error {
|
|
|
|
fn from(e: reqwest::Error) -> Self {
|
|
|
|
Error::Http(Arc::new(e))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<sigh::Error> for Error {
|
|
|
|
fn from(e: sigh::Error) -> Self {
|
|
|
|
Error::Signature(Arc::new(e))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<http::Error> for Error {
|
|
|
|
fn from(e: http::Error) -> Self {
|
|
|
|
Error::HttpReq(Arc::new(e))
|
|
|
|
}
|
|
|
|
}
|