aboutsummaryrefslogtreecommitdiff
path: root/src/api/common_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/common_error.rs
parent5a535788fc0a69950bbfdc6f189597c5e37a6e3b (diff)
downloadgarage-8033bdb0b4577133cff7d4d90a811ed8f3e13365.tar.gz
garage-8033bdb0b4577133cff7d4d90a811ed8f3e13365.zip
More precisions in errors & small refactoring
Diffstat (limited to 'src/api/common_error.rs')
-rw-r--r--src/api/common_error.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/api/common_error.rs b/src/api/common_error.rs
index b6dbf059..20f9f266 100644
--- a/src/api/common_error.rs
+++ b/src/api/common_error.rs
@@ -32,8 +32,8 @@ pub enum CommonError {
// These have to be error codes referenced in the S3 spec here:
// https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList
/// The bucket requested don't exists
- #[error(display = "Bucket not found")]
- NoSuchBucket,
+ #[error(display = "Bucket not found: {}", _0)]
+ NoSuchBucket(String),
/// Tried to create a bucket that already exist
#[error(display = "Bucket already exists")]
@@ -45,8 +45,8 @@ pub enum CommonError {
// Category: bad request
/// Bucket name is not valid according to AWS S3 specs
- #[error(display = "Invalid bucket name")]
- InvalidBucketName,
+ #[error(display = "Invalid bucket name: {}", _0)]
+ InvalidBucketName(String),
}
impl CommonError {
@@ -62,9 +62,9 @@ impl CommonError {
}
CommonError::BadRequest(_) => StatusCode::BAD_REQUEST,
CommonError::Forbidden(_) => StatusCode::FORBIDDEN,
- CommonError::NoSuchBucket => StatusCode::NOT_FOUND,
+ CommonError::NoSuchBucket(_) => StatusCode::NOT_FOUND,
CommonError::BucketNotEmpty | CommonError::BucketAlreadyExists => StatusCode::CONFLICT,
- CommonError::InvalidBucketName => StatusCode::BAD_REQUEST,
+ CommonError::InvalidBucketName(_) => StatusCode::BAD_REQUEST,
}
}
@@ -80,10 +80,10 @@ impl CommonError {
"InternalError"
}
CommonError::BadRequest(_) => "InvalidRequest",
- CommonError::NoSuchBucket => "NoSuchBucket",
+ CommonError::NoSuchBucket(_) => "NoSuchBucket",
CommonError::BucketAlreadyExists => "BucketAlreadyExists",
CommonError::BucketNotEmpty => "BucketNotEmpty",
- CommonError::InvalidBucketName => "InvalidBucketName",
+ CommonError::InvalidBucketName(_) => "InvalidBucketName",
}
}