From 691ed5095785dc43f0b4ac7c9d9d78111518f253 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Thu, 31 Mar 2022 08:44:48 +0500 Subject: [PATCH] use constant for ErrBucketNotEmpty --- weed/s3api/s3api_bucket_handlers.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index 245325377..b8f2c2f7a 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -3,6 +3,7 @@ package s3api import ( "context" "encoding/xml" + "errors" "fmt" "math" "net/http" @@ -154,7 +155,7 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque return fmt.Errorf("failed to list bucket %s: %v", bucket, err) } if len(entries) > 0 { - return fmt.Errorf("BucketNotEmpty") + return errors.New(s3err.GetAPIError(s3err.ErrBucketNotEmpty).Code) } } @@ -173,7 +174,7 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque if err != nil { s3ErrorCode := s3err.ErrInternalError - if err.Error() == "BucketNotEmpty" { + if err.Error() == s3err.GetAPIError(s3err.ErrBucketNotEmpty).Code { s3ErrorCode = s3err.ErrBucketNotEmpty } s3err.WriteErrorResponse(w, r, s3ErrorCode)