api: better handling of helper errors to distinguish error codes

This commit is contained in:
Alex Auvolat
2025-01-29 19:14:34 +01:00
parent a1d081ee84
commit 9f3c7c3720
12 changed files with 97 additions and 29 deletions
+15
View File
@@ -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 {