Skip to content

Commit

Permalink
feat: get status code from s3's seralization error message
Browse files Browse the repository at this point in the history
A unmarshalling error is returned from s3, get the status code and
report that to the user.
  • Loading branch information
MalinAhlberg committed Feb 26, 2025
1 parent 5e622b3 commit 358b611
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,16 @@ func ListFiles(config Config, prefix string) (result *s3.ListObjectsV2Output, er
Bucket: aws.String(config.AccessKey + "/"),
Prefix: aws.String(config.AccessKey + "/" + prefix),
})

if err != nil {
if strings.HasPrefix(err.Error(), "SerializationError") {
re := regexp.MustCompile(`(status code: \d*)`)
errorCode := re.FindString(err.Error())
if errorCode != "" {
err = fmt.Errorf("Problem connecting to s3: %s", errorCode)
}
}

return nil, fmt.Errorf("failed to list objects, reason: %v", err)
}

Expand Down

0 comments on commit 358b611

Please sign in to comment.