Skip to content

Commit b759ac6

Browse files
committed
releaser(aws): remove type assertion on errors
Signed-off-by: CrazyMax <[email protected]>
1 parent fbf879c commit b759ac6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

_releaser/aws.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"archive/zip"
55
"bytes"
66
"encoding/json"
7+
"errors"
78
"fmt"
89
"log"
910
"os"
@@ -143,13 +144,14 @@ func (s *AwsCloudfrontUpdateCmd) Run() error {
143144
FunctionName: aws.String(s.Function),
144145
})
145146
if err != nil {
146-
if aerr, ok := err.(awserr.Error); ok && aerr.Code() != lambda.ErrCodeResourceNotFoundException {
147+
var aerr awserr.Error
148+
if errors.As(err, &aerr) && aerr.Code() != lambda.ErrCodeResourceNotFoundException {
147149
return fmt.Errorf("cannot find lambda function %q: %w", s.Function, err)
148150
}
149151
_, err = svc.CreateFunction(&lambda.CreateFunctionInput{
150152
FunctionName: aws.String(s.Function),
151153
})
152-
if aerr, ok := err.(awserr.Error); ok && aerr.Code() != lambda.ErrCodeResourceConflictException {
154+
if errors.As(err, &aerr) && aerr.Code() != lambda.ErrCodeResourceConflictException {
153155
return err
154156
}
155157
}

0 commit comments

Comments
 (0)