aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-03 13:58:05 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:52:46 +0100
commitbeeef4758e5ec0d521179a799a3237c2c0368911 (patch)
treeeb2734647b3c6e62cef64a5f2b533ac694252c29 /src/api
parentd8ab5bdc3e20759e5ba8a6844393757da3539372 (diff)
downloadgarage-beeef4758e5ec0d521179a799a3237c2c0368911.tar.gz
garage-beeef4758e5ec0d521179a799a3237c2c0368911.zip
Some movement of helper code and refactoring of error handling
Diffstat (limited to 'src/api')
-rw-r--r--src/api/error.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/api/error.rs b/src/api/error.rs
index 828a2342..d6d4a1d7 100644
--- a/src/api/error.rs
+++ b/src/api/error.rs
@@ -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 {