Skip to content

Commit

Permalink
feat: support multiple error headers (#3852)
Browse files Browse the repository at this point in the history
This change takes the first header value from x-amzn-errortype
if multiple headers are provided.

An example curl output for a response that this works for:
```
HTTP/2 401
date: Tue, 09 Aug 2022 21:24:20 GMT
content-type: application/json
content-length: 92
x-amzn-requestid: xxxx
access-control-allow-origin: *
x-amzn-errortype: UnauthorizedError
x-amzn-errortype: UnauthorizedException
x-amz-apigw-id: xxxx
x-amzn-trace-id: Root=xxxx
```
In this instance this code will select the first header value.

See related - smithy-lang/smithy#1170
  • Loading branch information
DanielBauman88 committed Sep 6, 2022
1 parent 850c13f commit e2c4714
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | unde
if (typeof cleanValue === "number") {
cleanValue = cleanValue.toString();
}
if (cleanValue.indexOf(",") >= 0) {
cleanValue = cleanValue.split(",")[0];
}
if (cleanValue.indexOf(":") >= 0) {
cleanValue = cleanValue.split(":")[0];
}
Expand Down

0 comments on commit e2c4714

Please sign in to comment.