From 8033bdb0b4577133cff7d4d90a811ed8f3e13365 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 13 May 2022 19:36:17 +0200 Subject: More precisions in errors & small refactoring --- src/api/common_error.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/api/common_error.rs') 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", } } -- cgit v1.2.3