From beeef4758e5ec0d521179a799a3237c2c0368911 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 3 Jan 2022 13:58:05 +0100 Subject: Some movement of helper code and refactoring of error handling --- src/api/error.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/api') 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 for Error { } } +impl From 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 { -- cgit v1.2.3