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/admin | |
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 mainHEADmain
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/942
Diffstat (limited to 'src/api/admin')
-rw-r--r-- | src/api/admin/error.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/api/admin/error.rs b/src/api/admin/error.rs index 2668b42d..40d686e3 100644 --- a/src/api/admin/error.rs +++ b/src/api/admin/error.rs @@ -1,3 +1,5 @@ +use std::convert::TryFrom; + use err_derive::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; @@ -38,6 +40,19 @@ where } } +/// FIXME: helper errors are transformed into their corresponding variants +/// in the Error struct, but in many case a helper error should be considered +/// an internal error. +impl From<HelperError> for Error { + fn from(err: HelperError) -> Error { + match CommonError::try_from(err) { + Ok(ce) => Self::Common(ce), + Err(HelperError::NoSuchAccessKey(k)) => Self::NoSuchAccessKey(k), + Err(_) => unreachable!(), + } + } +} + impl CommonErrorDerivative for Error {} impl Error { |