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/s3/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/s3/error.rs')
-rw-r--r-- | src/api/s3/error.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/api/s3/error.rs b/src/api/s3/error.rs index 2855e0b3..22d2fe14 100644 --- a/src/api/s3/error.rs +++ b/src/api/s3/error.rs @@ -4,7 +4,10 @@ use err_derive::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; -use crate::common_error::CommonError; +use garage_model::helper::error::Error as HelperError; + +pub(crate) use crate::common_error::pass_helper_error; +use crate::common_error::{helper_error_as_internal, CommonError}; pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError}; use crate::generic_server::ApiError; use crate::helpers::*; @@ -87,6 +90,14 @@ where } } +// Helper errors are always passed as internal errors by default. +// To pass the specific error code back to the client, use `pass_helper_error`. +impl From<HelperError> for Error { + fn from(err: HelperError) -> Error { + Error::Common(helper_error_as_internal(err)) + } +} + impl CommonErrorDerivative for Error {} impl From<roxmltree::Error> for Error { |