mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-12 07:16:52 +00:00
api: better handling of helper errors to distinguish error codes
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user