diff options
author | Alex Auvolat <lx@deuxfleurs.fr> | 2025-01-31 18:18:04 +0100 |
---|---|---|
committer | Alex Auvolat <lx@deuxfleurs.fr> | 2025-01-31 18:18:29 +0100 |
commit | 9fa20d45bebab2a3f66b9721c3643dbd607d944d (patch) | |
tree | 4c5cc3dee19f7cbd9e146a90ef5cbddb052716d5 /src/api/common/signature/error.rs | |
parent | 9330fd79d3466051394f6d419a247d46da8f5151 (diff) | |
download | garage-9fa20d45bebab2a3f66b9721c3643dbd607d944d.tar.gz garage-9fa20d45bebab2a3f66b9721c3643dbd607d944d.zip |
wip: split garage_api into garage_api_{common,s3,k2v,admin}
Diffstat (limited to 'src/api/common/signature/error.rs')
-rw-r--r-- | src/api/common/signature/error.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/api/common/signature/error.rs b/src/api/common/signature/error.rs new file mode 100644 index 00000000..2d92a072 --- /dev/null +++ b/src/api/common/signature/error.rs @@ -0,0 +1,32 @@ +use err_derive::Error; + +use crate::common_error::CommonError; +pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError}; + +/// Errors of this crate +#[derive(Debug, Error)] +pub enum Error { + #[error(display = "{}", _0)] + /// Error from common error + Common(CommonError), + + /// Authorization Header Malformed + #[error(display = "Authorization header malformed, unexpected scope: {}", _0)] + AuthorizationHeaderMalformed(String), + + // Category: bad request + /// The request contained an invalid UTF-8 sequence in its path or in other parameters + #[error(display = "Invalid UTF-8: {}", _0)] + InvalidUtf8Str(#[error(source)] std::str::Utf8Error), +} + +impl<T> From<T> for Error +where + CommonError: From<T>, +{ + fn from(err: T) -> Self { + Error::Common(CommonError::from(err)) + } +} + +impl CommonErrorDerivative for Error {} |