aboutsummaryrefslogtreecommitdiff
path: root/src/api/admin/error.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-13 19:36:17 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-13 19:36:17 +0200
commit8033bdb0b4577133cff7d4d90a811ed8f3e13365 (patch)
tree5f4abf43f18322c64db68787d91a227aa4421b97 /src/api/admin/error.rs
parent5a535788fc0a69950bbfdc6f189597c5e37a6e3b (diff)
downloadgarage-8033bdb0b4577133cff7d4d90a811ed8f3e13365.tar.gz
garage-8033bdb0b4577133cff7d4d90a811ed8f3e13365.zip
More precisions in errors & small refactoring
Diffstat (limited to 'src/api/admin/error.rs')
-rw-r--r--src/api/admin/error.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/api/admin/error.rs b/src/api/admin/error.rs
index 38dfe5b6..cd7e6af7 100644
--- a/src/api/admin/error.rs
+++ b/src/api/admin/error.rs
@@ -18,8 +18,8 @@ pub enum Error {
// Category: cannot process
/// The API access key does not exist
- #[error(display = "Access key not found")]
- NoSuchAccessKey,
+ #[error(display = "Access key not found: {}", _0)]
+ NoSuchAccessKey(String),
}
impl<T> From<T> for Error
@@ -38,9 +38,11 @@ impl From<HelperError> for Error {
match err {
HelperError::Internal(i) => Self::CommonError(CommonError::InternalError(i)),
HelperError::BadRequest(b) => Self::CommonError(CommonError::BadRequest(b)),
- HelperError::InvalidBucketName(_) => Self::CommonError(CommonError::InvalidBucketName),
- HelperError::NoSuchBucket(_) => Self::CommonError(CommonError::NoSuchBucket),
- HelperError::NoSuchAccessKey(_) => Self::NoSuchAccessKey,
+ HelperError::InvalidBucketName(n) => {
+ Self::CommonError(CommonError::InvalidBucketName(n))
+ }
+ HelperError::NoSuchBucket(n) => Self::CommonError(CommonError::NoSuchBucket(n)),
+ HelperError::NoSuchAccessKey(n) => Self::NoSuchAccessKey(n),
}
}
}
@@ -49,7 +51,7 @@ impl Error {
fn code(&self) -> &'static str {
match self {
Error::CommonError(c) => c.aws_code(),
- Error::NoSuchAccessKey => "NoSuchAccessKey",
+ Error::NoSuchAccessKey(_) => "NoSuchAccessKey",
}
}
}
@@ -59,7 +61,7 @@ impl ApiError for Error {
fn http_status_code(&self) -> StatusCode {
match self {
Error::CommonError(c) => c.http_status_code(),
- Error::NoSuchAccessKey => StatusCode::NOT_FOUND,
+ Error::NoSuchAccessKey(_) => StatusCode::NOT_FOUND,
}
}