diff --git a/controllers/s3utils.go b/controllers/s3utils.go index 72c7d7f966..6baafe1232 100644 --- a/controllers/s3utils.go +++ b/controllers/s3utils.go @@ -224,8 +224,8 @@ func (s *s3ObjectStore) CreateBucket(bucket string) (err error) { cbInput := &s3.CreateBucketInput{Bucket: &bucket} if err = cbInput.Validate(); err != nil { - return fmt.Errorf("create bucket input validation failed for %s, err %w", - bucket, err) + errMsgPrefix := fmt.Errorf("create bucket input validation failed for %s", bucket) + return processAwsError(errMsgPrefix, err) } _, err = s.client.CreateBucket(cbInput) @@ -236,8 +236,8 @@ func (s *s3ObjectStore) CreateBucket(bucket string) (err error) { case s3.ErrCodeBucketAlreadyExists: case s3.ErrCodeBucketAlreadyOwnedByYou: default: - return fmt.Errorf("failed to create bucket %s, %w", - bucket, err) + return fmt.Errorf("failed to create bucket %s, %s: %s", + bucket, aerr.Code(), aerr.Message()) } } } @@ -265,14 +265,14 @@ func (s *s3ObjectStore) DeleteBucket(bucket string) ( dbInput := &s3.DeleteBucketInput{Bucket: &bucket} if err = dbInput.Validate(); err != nil { - return fmt.Errorf("delete bucket input validation failed for %s, err %w", - bucket, err) + errMsgPrefix := fmt.Errorf("delete bucket input validation failed for %s", bucket) + return processAwsError(errMsgPrefix, err) } _, err = s.client.DeleteBucket(dbInput) if err != nil && !isAwsErrCodeNoSuchBucket(err) { - return fmt.Errorf("failed to delete bucket %s, %w", - bucket, err) + errMsgPrefix := fmt.Errorf("failed to delete bucket %s", bucket) + return processAwsError(errMsgPrefix, err) } return nil @@ -301,9 +301,10 @@ func (s *s3ObjectStore) PurgeBucket(bucket string) ( return nil // Not an error } - return fmt.Errorf("unable to ListKeys "+ - "from endpoint %s bucket %s, %w", - s.s3Endpoint, bucket, err) + errMsgPrefix := fmt.Errorf("unable to ListKeys "+ + "from endpoint %s bucket %s", + s.s3Endpoint, bucket) + return processAwsError(errMsgPrefix, err) } for _, key := range keys {