buzzrelay/src/error.rs

46 lines
1.1 KiB
Rust
Raw Normal View History

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")]
Json(#[from] Arc<serde_json::Error>),
2023-05-14 20:58:00 +00:00
#[error("Signature error")]
Signature(#[from] Arc<sigh::Error>),
#[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")]
HttpReq(#[from] Arc<http::Error>),
2023-05-14 20:58:00 +00:00
#[error("HTTP client error")]
Http(#[from] Arc<reqwest::Error>),
2023-05-14 20:58:00 +00:00
#[error("Invalid URI")]
InvalidUri,
#[error("Error response from remote")]
Response(String),
}
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))
}
}