Merge branch 'main' into next-v2

This commit is contained in:
Alex Auvolat
2025-02-01 19:07:17 +01:00
77 changed files with 869 additions and 840 deletions
+8 -15
View File
@@ -6,17 +6,19 @@ use hyper::{HeaderMap, StatusCode};
pub use garage_model::helper::error::Error as HelperError;
use crate::common_error::CommonError;
pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError};
use crate::generic_server::ApiError;
use crate::helpers::*;
use garage_api_common::common_error::{commonErrorDerivative, CommonError};
pub use garage_api_common::common_error::{
CommonErrorDerivative, OkOrBadRequest, OkOrInternalError,
};
use garage_api_common::generic_server::ApiError;
use garage_api_common::helpers::*;
/// Errors of this crate
#[derive(Debug, Error)]
pub enum Error {
#[error(display = "{}", _0)]
/// Error from common error
Common(CommonError),
Common(#[error(source)] CommonError),
// Category: cannot process
/// The API access key does not exist
@@ -31,14 +33,7 @@ pub enum Error {
KeyAlreadyExists(String),
}
impl<T> From<T> for Error
where
CommonError: From<T>,
{
fn from(err: T) -> Self {
Error::Common(CommonError::from(err))
}
}
commonErrorDerivative!(Error);
/// FIXME: helper errors are transformed into their corresponding variants
/// in the Error struct, but in many case a helper error should be considered
@@ -53,8 +48,6 @@ impl From<HelperError> for Error {
}
}
impl CommonErrorDerivative for Error {}
impl Error {
pub fn code(&self) -> &'static str {
match self {