Skip to content

Commit

Permalink
fix: wrong aws error check
Browse files Browse the repository at this point in the history
  • Loading branch information
mingrammer committed Apr 25, 2022
1 parent 43ff395 commit d9a97a8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kinesumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/daangn/kinesumer/pkg/xrand"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis"
Expand Down Expand Up @@ -348,8 +349,11 @@ func (k *Kinesumer) registerConsumers() error {
)

// In case of that consumer is already registered.
var riue kinesis.ResourceInUseException
if errors.As(err, &riue) {
var awsErr awserr.Error
if errors.As(err, &awsErr) {
if awsErr.Code() != "ResourceInUseException" {
return errors.WithStack(err)
}
lOutput, err := k.client.ListStreamConsumers(
&kinesis.ListStreamConsumersInput{
MaxResults: aws.Int64(20),
Expand All @@ -373,7 +377,6 @@ func (k *Kinesumer) registerConsumers() error {
streamARN: *streamARN,
}
continue

} else if err != nil {
return errors.WithStack(err)
}
Expand Down

0 comments on commit d9a97a8

Please sign in to comment.