Commit f928e9d5 by jason.mei

fix(aws): simplify HTTP status code extraction from AWS errors

parent a925b8ec
...@@ -22,19 +22,15 @@ import ( ...@@ -22,19 +22,15 @@ import (
"github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime" "github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
bedrockruntimeTypes "github.com/aws/aws-sdk-go-v2/service/bedrockruntime/types" bedrockruntimeTypes "github.com/aws/aws-sdk-go-v2/service/bedrockruntime/types"
"github.com/aws/smithy-go"
"github.com/aws/smithy-go/auth/bearer" "github.com/aws/smithy-go/auth/bearer"
) )
// getAwsErrorStatusCode extracts HTTP status code from AWS SDK error // getAwsErrorStatusCode extracts HTTP status code from AWS SDK error
func getAwsErrorStatusCode(err error) int { func getAwsErrorStatusCode(err error) int {
var apiErr smithy.APIError // Check for HTTP response error which contains status code
if errors.As(err, &apiErr) { var httpErr interface{ HTTPStatusCode() int }
// Check for HTTP response error which contains status code if errors.As(err, &httpErr) {
var httpErr interface{ HTTPStatusCode() int } return httpErr.HTTPStatusCode()
if errors.As(err, &httpErr) {
return httpErr.HTTPStatusCode()
}
} }
// Default to 500 if we can't determine the status code // Default to 500 if we can't determine the status code
return http.StatusInternalServerError return http.StatusInternalServerError
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment