Skip to content

Commit e2c4714

Browse files
feat: support multiple error headers (#3852)
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
1 parent 850c13f commit e2c4714

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/load-json-error-code-stub.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | unde
99
if (typeof cleanValue === "number") {
1010
cleanValue = cleanValue.toString();
1111
}
12+
if (cleanValue.indexOf(",") >= 0) {
13+
cleanValue = cleanValue.split(",")[0];
14+
}
1215
if (cleanValue.indexOf(":") >= 0) {
1316
cleanValue = cleanValue.split(":")[0];
1417
}

0 commit comments

Comments
 (0)