Some movement of helper code and refactoring of error handling

This commit is contained in:
Alex Auvolat
2022-01-03 13:58:05 +01:00
parent d8ab5bdc3e
commit beeef4758e
17 changed files with 137 additions and 66 deletions
+10
View File
@@ -4,6 +4,7 @@ use err_derive::Error;
use hyper::header::HeaderValue;
use hyper::{HeaderMap, StatusCode};
use garage_model::helper::error::Error as HelperError;
use garage_util::error::Error as GarageError;
use crate::s3_xml;
@@ -83,6 +84,15 @@ impl From<quick_xml::de::DeError> for Error {
}
}
impl From<HelperError> for Error {
fn from(err: HelperError) -> Self {
match err {
HelperError::Internal(i) => Self::InternalError(i),
HelperError::BadRequest(b) => Self::BadRequest(b),
}
}
}
impl Error {
/// Get the HTTP status code that best represents the meaning of the error for the client
pub fn http_status_code(&self) -> StatusCode {