fix: errNoSuchPolicy should use errors.Is (#16656)

This commit is contained in:
jiuker 2023-02-25 16:01:37 +08:00 committed by GitHub
parent cd3a2de5a3
commit b49b39e99d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -2001,8 +2001,6 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
apiErr = ErrAdminGroupNotEmpty apiErr = ErrAdminGroupNotEmpty
case errNoSuchJob: case errNoSuchJob:
apiErr = ErrAdminNoSuchJob apiErr = ErrAdminNoSuchJob
case errNoSuchPolicy:
apiErr = ErrAdminNoSuchPolicy
case errNoPolicyToAttachOrDetach: case errNoPolicyToAttachOrDetach:
apiErr = ErrAdminPolicyChangeAlreadyApplied apiErr = ErrAdminPolicyChangeAlreadyApplied
case errSignatureMismatch: case errSignatureMismatch:
@ -2054,7 +2052,6 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
apiErr = ErrKMSKeyNotFoundException apiErr = ErrKMSKeyNotFoundException
case errKMSDefaultKeyAlreadyConfigured: case errKMSDefaultKeyAlreadyConfigured:
apiErr = ErrKMSDefaultKeyAlreadyConfigured apiErr = ErrKMSDefaultKeyAlreadyConfigured
case context.Canceled, context.DeadlineExceeded: case context.Canceled, context.DeadlineExceeded:
apiErr = ErrOperationTimedOut apiErr = ErrOperationTimedOut
case errDiskNotFound: case errDiskNotFound:
@ -2069,6 +2066,11 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
apiErr = ErrObjectLockInvalidHeaders apiErr = ErrObjectLockInvalidHeaders
case objectlock.ErrMalformedXML: case objectlock.ErrMalformedXML:
apiErr = ErrMalformedXML apiErr = ErrMalformedXML
default:
switch {
case errors.Is(err, errNoSuchPolicy):
apiErr = ErrAdminNoSuchPolicy
}
} }
// Compression errors // Compression errors