diff options
author | Alex <lx@deuxfleurs.fr> | 2025-01-29 18:25:44 +0000 |
---|---|---|
committer | Alex <lx@deuxfleurs.fr> | 2025-01-29 18:25:44 +0000 |
commit | ab71544499679685877cd7bd683ba4556b4331f2 (patch) | |
tree | 7445be8428cfccd0996109b23a06ec2b7b959f40 /src/api/k2v/error.rs | |
parent | 991edbe02c9493e932614f1b801fe2bbdf020c53 (diff) | |
parent | 9f3c7c3720d323bc9df3892197e6da5d89d1b84a (diff) | |
download | garage-ab71544499679685877cd7bd683ba4556b4331f2.tar.gz garage-ab71544499679685877cd7bd683ba4556b4331f2.zip |
Merge pull request 'api: better handling of helper errors to distinguish error codes' (#942) from fix-getkeyinfo-404 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/942
Diffstat (limited to 'src/api/k2v/error.rs')
-rw-r--r-- | src/api/k2v/error.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/api/k2v/error.rs b/src/api/k2v/error.rs index 16479227..dbe4be2c 100644 --- a/src/api/k2v/error.rs +++ b/src/api/k2v/error.rs @@ -3,6 +3,7 @@ use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; use crate::common_error::CommonError; +pub(crate) use crate::common_error::{helper_error_as_internal, pass_helper_error}; pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError}; use crate::generic_server::ApiError; use crate::helpers::*; @@ -28,6 +29,10 @@ pub enum Error { #[error(display = "Invalid base64: {}", _0)] InvalidBase64(#[error(source)] base64::DecodeError), + /// Invalid causality token + #[error(display = "Invalid causality token")] + InvalidCausalityToken, + /// The client asked for an invalid return format (invalid Accept header) #[error(display = "Not acceptable: {}", _0)] NotAcceptable(String), @@ -72,6 +77,7 @@ impl Error { Error::AuthorizationHeaderMalformed(_) => "AuthorizationHeaderMalformed", Error::InvalidBase64(_) => "InvalidBase64", Error::InvalidUtf8Str(_) => "InvalidUtf8String", + Error::InvalidCausalityToken => "CausalityToken", } } } @@ -85,7 +91,8 @@ impl ApiError for Error { Error::NotAcceptable(_) => StatusCode::NOT_ACCEPTABLE, Error::AuthorizationHeaderMalformed(_) | Error::InvalidBase64(_) - | Error::InvalidUtf8Str(_) => StatusCode::BAD_REQUEST, + | Error::InvalidUtf8Str(_) + | Error::InvalidCausalityToken => StatusCode::BAD_REQUEST, } } |