72 lines
2.2 KiB
Rust
72 lines
2.2 KiB
Rust
//! Error messages returned by this library
|
|
|
|
use std::string::FromUtf8Error;
|
|
|
|
use http_signature_normalization_reqwest::SignError;
|
|
use openssl::error::ErrorStack;
|
|
use url::Url;
|
|
|
|
/// Error messages returned by this library
|
|
#[derive(thiserror::Error, Debug)]
|
|
pub enum Error {
|
|
/// Object was not found in local database
|
|
#[error("Object was not found in local database")]
|
|
NotFound,
|
|
/// Request limit was reached during fetch
|
|
#[error("Request limit was reached during fetch")]
|
|
RequestLimit,
|
|
/// Response body limit was reached during fetch
|
|
#[error("Response body limit was reached during fetch")]
|
|
ResponseBodyLimit,
|
|
/// Object to be fetched was deleted
|
|
#[error("Fetched remote object {0} which was deleted")]
|
|
ObjectDeleted(Url),
|
|
/// url verification error
|
|
#[error("URL failed verification: {0}")]
|
|
UrlVerificationError(&'static str),
|
|
/// Incoming activity has invalid digest for body
|
|
#[error("Incoming activity has invalid digest for body")]
|
|
ActivityBodyDigestInvalid,
|
|
/// Incoming activity has invalid signature
|
|
#[error("Incoming activity has invalid signature")]
|
|
ActivitySignatureInvalid,
|
|
/// Failed to resolve actor via webfinger
|
|
#[error("Failed to resolve actor via webfinger")]
|
|
WebfingerResolveFailed,
|
|
/// Failed to resolve actor via webfinger
|
|
#[error("Webfinger regex failed to match")]
|
|
WebfingerRegexFailed,
|
|
/// JSON Error
|
|
#[error(transparent)]
|
|
Json(#[from] serde_json::Error),
|
|
/// Reqwest Middleware Error
|
|
#[error(transparent)]
|
|
ReqwestMiddleware(#[from] reqwest_middleware::Error),
|
|
/// Reqwest Error
|
|
#[error(transparent)]
|
|
Reqwest(#[from] reqwest::Error),
|
|
/// UTF-8 error
|
|
#[error(transparent)]
|
|
Utf8(#[from] FromUtf8Error),
|
|
/// Url Parse
|
|
#[error(transparent)]
|
|
UrlParse(#[from] url::ParseError),
|
|
/// Signing errors
|
|
#[error(transparent)]
|
|
SignError(#[from] SignError),
|
|
/// Other generic errors
|
|
#[error("{0}")]
|
|
Other(String),
|
|
}
|
|
|
|
impl From<ErrorStack> for Error {
|
|
fn from(value: ErrorStack) -> Self {
|
|
Error::Other(value.to_string())
|
|
}
|
|
}
|
|
|
|
impl PartialEq for Error {
|
|
fn eq(&self, other: &Self) -> bool {
|
|
std::mem::discriminant(self) == std::mem::discriminant(other)
|
|
}
|
|
}
|